基本上我试着用一个起始变量在我的代码中运行它。 然后给变量加1,然后重新运行代码并重复,直到我停止它。现在我已经写了这篇文章,但它离我要完成的目标还差得很远。我走的是正确的道路还是完全错了?你知道吗
代码-
import requests
from bs4 import BeautifulSoup as bs
import re
start = 1
print("starting number: ", start)
i = 0
number = 500
while i < number:
url = "https://randomsite.com/{0}".format(start + i)
try:
print(int(start) + i)
response1 = requests.get(url)
name = re.findall(('analyticsKey":"([^"]+)'), response1.text)
ids = re.findall(('id":"([^"]+)'), response1.text)
print(name)
print("")
print(ids)
print("")
except:
pass
i += 1
目前没有回答
相关问题 更多 >
编程相关推荐