1、介绍小白可以学会的爬虫
1.1装chrome第三方库插件:XPath Helper
下载地址:https://chrome.google.com/webstore/detail/xpath-helper/hgimnogjllphhhkhlmebbmlgjoejdpjl
使用链接地址:https://zhaoolee.com/ChromeAppHeroes/page/015_xpath_helper.html
1、被爬地址:https://cuiqingcai.com/category/technique/python
2、操作办法
第一步:
第二步:调代码
第三步:调出1条出来
第四步:调出多条出来
结果:
1.2贴代码
备注:(requests库和etree库提前安装,安装地址:https://blog.csdn.net/weixin_41665637/article/details/99292935)
代码模板:
import requests
from lxml import etree
r=requests.get('https://cuiqingcai.com/category/technique/python').content
topic=etree.HTML(r)
title=topic.xpath('/html/body/section/div[2]/div/article/header/h2/a/text()')
img=topic.xpath('/html/body/section/div[2]/div/article/div/a/img/@src')
#
# for x in html:
# print(x,end="")
for i in img:
print(i)
备注:这个办法一般可以把新闻的除内容外的所有信息爬到
怎么写
右键去粘,但是如果数据还是显示有问题,则可以把内容补充全,补充的办法是给内容后加@【内容】