import requests
from bs4 import BeautifulSoup
import openai
#write each line of nuclear.txt to a list
with open('nuclear.txt', 'r') as f:
lines = f.readlines()
#remove the newline character from each line
lines = [line.rstrip() for line in lines]
#gather the text from each website and add it to a new txt file
for line in lines:
r = requests.get(line)
soup = BeautifulSoup(r.text, 'html.parser')
text = soup.get_text()
with open('nuclear_text.txt', 'a') as f:
f.write(text)
Run Code Online (Sandbox Code Playgroud)
我正在尝试导入 openai,但它不断抛出错误“未找到模块”。我已经完成了 pip install openai 并下载了它,但它似乎是错误的 python 版本。如何选择正确的 …