基本上我试图通过我的代码运行一个起始变量。 然后将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