![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
爬虫
蘑菇头上不长草
这个作者很懒,什么都没留下…
展开
-
Python: xpath定位元素方法(练习1)
Python: xpath定位元素方法写个爬取小破站各个分类的热门标签来简单地练习下xpath定位。(小小小练习~)参考:xpath语法详解lxml.etree - 简书常用etree.HTML(text):调用HTML类对HTML文本进行初始化,成功构造XPath解析对象。会自动加上html和body元素(如果原字符串没有的话。返回Element类。etree.tostring(html):使用tostring可以提取出xml中所含的全部文本 。fromstring(som原创 2020-11-14 23:18:31 · 575 阅读 · 0 评论 -
Python: Requests 库应用练习(小说爬虫)
爬虫小作业:1.导入库import requestsimport re2.获取网页def get_page(url): headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36'} r = requests.get(url=url, headers=head原创 2020-11-08 22:26:12 · 406 阅读 · 0 评论