update spider/doutu.py.

master
newrain001 3 years ago committed by Gitee
parent 43961c21eb
commit b2e53a55b4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
  1. 8
      spider/doutu.py

@ -15,18 +15,22 @@ from lxml import etree
import time
import os
from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def getUrl():
header = {
'User-Agent': 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36',
'Referer': 'www.doutula.com',
}
html = requests.get('https://www.doutula.com/photo/list', headers=header)
html = requests.get('https://www.doutula.com/photo/list', headers=header, verify=False)
if html.status_code == 200:
e = etree.HTML(html.text)
url = e.xpath('//ul/li/div/div/a/img/@data-original')
for i in url:
name = i.split("/")[-1]
result = requests.get(i)
result = requests.get(i,headers=header, verify=False)
if not os.path.exists('./image'):
os.mkdir('image')
with open(f'image/{name}', 'wb') as f:

Loading…
Cancel
Save