使用selenium下载煎蛋网加密妹子图
【摘要】 #!/usr/bin/env python# -*- coding: utf-8 -*-#coding=utf-8 import requests import urllib.requestfrom bs4 import BeautifulSoupfrom selenium import webdriver urls = ('http://jandan.net/ooxx/p...
-
#!/usr/bin/env python
-
# -*- coding: utf-8 -*-
-
#coding=utf-8
-
import requests
-
import urllib.request
-
from bs4 import BeautifulSoup
-
from selenium import webdriver
-
-
urls = ('http://jandan.net/ooxx/page-{}#comments'.format(i) for i in range(300,327))
-
x = 1
-
-
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0'
-
-
-
driver=webdriver.Firefox()
-
-
driver.maximize_window()
-
-
-
-
for url in urls:
-
print ("正在访问{}".format(url))
-
try:
-
driver.get(url)
-
driver.implicitly_wait(10)
-
data = driver.page_source
-
soup = BeautifulSoup(data, 'lxml')
-
hrefs = soup.find_all('a',class_="view_img_link")
-
except:
-
print ("访问异常!")
-
continue
-
-
print ("开始下载")
-
for href in hrefs:
-
img = href.get('href')
-
img = "http:" + img
-
if img[-3:] != 'jpg':
-
continue
-
print ("正在下载第{}张图片".format(x))
-
urllib.request.urlretrieve(img,'%s.jpg' % (x))
-
x = x+1
-
-
-
-
-
-
-
-
文章来源: blog.csdn.net,作者:悦来客栈的老板,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/qq523176585/article/details/78638017
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)