This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
importpandasaspd
importrequests
frombs4importBeautifulSoup
importrandom
fromtimeimportsleep
fromtqdmimporttqdm
defget_page(url):
n=3
whileTrue:
try:
# sleep(random.uniform(1, 2)) # 随机出现1-2之间的数,包含小数
headers={
'Cookie':'OCSSID=4df0bjva6j7ejussu8al3eqo03',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36',