首页 > 编程知识 正文

漂亮的小爬虫图片,python实现简单爬虫功能

时间:2023-05-03 05:18:27 阅读:115352 作者:595

1 .在1.xpath helper上制作小爬虫必须先安装谷歌插件(仅限谷歌浏览器)。 称为XPathHelper

网盘:https://pan.Baidu.com/s/1 phxpkllx0- ba7idxpgrhza

密码: yuuv具体怎么安装,人很好,链接都帮你找了:

打开3359 www.cn blogs.com/baxian Hua/p/8878268.html 3360

33559 theater.mtime.com/China _ Beijing

然后,f12打开web源代码并打开xpath。 下面是图

我相信你这么聪明能理解

以下是python代码: import urllib.requestfromlxmlimportetreeurl=' http://theater.mtime.com/China _ Beijing/' web page=urling txt=web page.read (txt=txt.decode (utf-8 ) ) html=etree.html ) txt ) html _ data=html.xpl

2 .用正则表达式匹配的灵活性变强。 你必须熟悉正则表达式。 原理是爬网整个网页的源代码

然后用正则表达式进行匹配

这个直接贴代码吧

import urllib.requestimportreurl=' http://theater.mtime.com/China _ Beijing/' # web源代码web page=ur lib.request . ',text ) #字符串操作RS1=str(RS ).split ({ ' } set _ list=[ ] foriinrs 1: film _ id=I [ 53360 ].split ),'() 0 film_id] ) forIinset_list:print(str(I ).strip('[ ).replace (',''').replace () () )

that’sover

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