我运行代码很好,然后我调整代码并保存并关闭它,试图再次运行它并得到语法错误。我愚蠢的自己没有备份原始代码,现在我所做的任何更改似乎都无法修复它。我检查了网站的源代码,并没有改变。甚至在检查网站之前就出错了。关于我忽略的任何建议?
import requests
import time
import bs4
import sys
sys.stdout = open("links2.txt", "a")
for x in range(0, 100000):
try:
URL = f'https://wesbite.com/{x}'
page = requests.get(URL)
time.sleep(1)
soup = BeautifulSoup(page.content, 'html.parser')
website = "https://v.website.com/"
for links in soup.find('div',id='view').find_all('a'):
parts = links['href'].split("/")
new_link = parts[1].replace(parts[1], website) + '/'.join(parts[2:]) + ".mp4"
print(new_link)
except:
continue
它在以下行报告语法错误:URL = f'https://wesbite.com/{x}'
ibeautiful
相关分类