首页 > 编程知识 正文

python做动漫,漫画抓取

时间:2023-05-06 03:17:59 阅读:112777 作者:535

爬网URL=https://www.u17.com/chapter/26636.html # image _ id=221085

登上充满妖气的漫画,本人的谷歌浏览器获取的信息:

位置selector:#cur_img_221085

属性位置:在tc comic_read_img框下

开始爬取

URL=' https://www.u17.com/chapter/26636.html # image _ id=221085 ' resp=requests.get (URL ) print (resp.teted ) 因此,可以判断该部分img图像是由js动态地生成的。

原因: requests获取静态HTML语句的内容

当然,动态加载的网页也可以自然地爬上去

准备:

pip安装序列号

下载PhantomJS

下载地址: https://phantom js.org/download.html

或http://NPM.Tao Bao.org/dist/phantom js /

环境变量path加入phantomjs/lhzdll即可

importrequestsfrombs4importbeautifulsoupfromseleniumimportwebdriverpic _ list=[ ] URL=' https://www.u17.com/chapter/(3359 image _ id=8108355 ' driver=web driver.phantom js (executable _ path=' d 3360/program files (x86 )/phantom js ) ' html.parser ' ) result=soup.find_all ) img ), class_='image_cache loading ' ) forimg _ srcinresult 3360 if img _ src [ ' data-src ' ] not inpic _ list 3365365374; list 605.1.15 ) khtml, like Gecko )版本/13.0.3移动/15e 148 safari ' connection ' : ' keep-alive ' } forimg _ src inpic _ list : count=1resp=requests.get (img _ src ) f=open 'wb ' ) f.write(resp.content ) cont 但是,当前的Selenium版本将放弃PhantomJS,但不影响程序的运行

user warning : seleniumsupportforphantomjshasbeendeprecated,pleaseuseheadlessversionsofchromeorfirefoxinsteadwarnings.warard

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。