import requests
import urllib.request as u
import random
from bs4 import BeautifulSoup as Be
#代理ip,opener
#选择ip
ip=['101.200.127.149:3129','58.20.184.187:9091',\
'58.20.184.187:9091','183.247.211.156:30001']
ip_=random.choice(ip)
#创建opener
proxy=u.ProxyHandler({'http':ip_})
opener=u.build_opener(proxy)
u.install_opener(opener)
#header
cookie="Hm_lvt_1060da23a20238049f3e377d46f7e478=1659877599,1659878742,1659879750,1659881285; wordpress_test_cookie=WP+Cookie+check; wordpress_logged_in_5e2cce81a5cb57f53e7a18f30edb5d19=SabcdA%7C1660054371%7CW042ESC1NoLSJOkN2CBKjKsio1Zi6BWwOcgB7sbl3MK%7C489c6ce7516488747e9f2dce79213d662af2df\
36d1dda1548fb9589d02b4b893; Hm_lpvt_1060da23a20238049f3e377d46f7e478=1659881684"
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 \
(KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.77"
,"cookie":cookie}
#获取源码
url='https://www.xiurenwang.cc/10599.html'
response=requests.get(url,headers=headers)
content=response.content.decode('utf-8')
soup=Be(content,'lxml')
d_list=soup.find_all("div",id="image")
|