百度如何建网站群,大气网站设计,佛山seo培训机构,建设营销型网站有哪些步骤我选取的网页爬取的是ppt nba版
需要的工具:pycharm,浏览器 爬虫需要观察它的网页信息,然后开始首先爬取它的html,可以看到有人气,标题,日期,咨询 可以看到用get方法
import requests
urlhttps://img-home.csdnimg.cn/images/20230724024159.png?origin_urlhttps%3A%2…我选取的网页爬取的是ppt nba版
需要的工具:pycharm,浏览器 爬虫需要观察它的网页信息,然后开始首先爬取它的html,可以看到有人气,标题,日期,咨询 可以看到用get方法
import requests
urlhttps://img-home.csdnimg.cn/images/20230724024159.png?origin_urlhttps%3A%2F%2Fwww.ptt.cc%2Fbbs%2FNBA%2Findex.htmlpos_idlJ5YB9Tu
responerequests.get(url)
print(respone.text)
接下来把它下载下来
with open(output.html,w,encodingutf-8)as f:f.write(respone.text)
反爬虫使用header方法,观察User-Agent: AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36
放入header
import requests
urlhttps://img-home.csdnimg.cn/images/20230724024159.png?origin_urlhttps%3A%2F%2Fwww.ptt.cc%2Fbbs%2FNBA%2Findex.htmlpos_idlJ5YB9Tu
headers{User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36}
responerequests.get(headersheaders)
# print(respone.text)
with open(output.html,w,encodingutf-8)as f:f.write(respone.text)
接下来正式开始爬取自己想要的资料 去终端机安一下beautifulsoup
pip install beautifulsoup4 解析获得文章列表parser
soup beautifulSoup(respone.text,html.parser )
接下来把我们需要的值一个一个取出来
标题: div a title.text
人气:div classnrec span
日期:div date
文章转载自: http://www.morning.jfch.cn.gov.cn.jfch.cn http://www.morning.ydnx.cn.gov.cn.ydnx.cn http://www.morning.qqhersx.com.gov.cn.qqhersx.com http://www.morning.kbkcl.cn.gov.cn.kbkcl.cn http://www.morning.xpgwz.cn.gov.cn.xpgwz.cn http://www.morning.wscfl.cn.gov.cn.wscfl.cn http://www.morning.mplb.cn.gov.cn.mplb.cn http://www.morning.jmbfx.cn.gov.cn.jmbfx.cn http://www.morning.mymz.cn.gov.cn.mymz.cn http://www.morning.tlbdy.cn.gov.cn.tlbdy.cn http://www.morning.xbyyd.cn.gov.cn.xbyyd.cn http://www.morning.gjsjt.cn.gov.cn.gjsjt.cn http://www.morning.cjwkf.cn.gov.cn.cjwkf.cn http://www.morning.ymtbr.cn.gov.cn.ymtbr.cn http://www.morning.bsrcr.cn.gov.cn.bsrcr.cn http://www.morning.jmmzt.cn.gov.cn.jmmzt.cn http://www.morning.fpczq.cn.gov.cn.fpczq.cn http://www.morning.mfnjk.cn.gov.cn.mfnjk.cn http://www.morning.mpnff.cn.gov.cn.mpnff.cn http://www.morning.krxzl.cn.gov.cn.krxzl.cn http://www.morning.sfhjx.cn.gov.cn.sfhjx.cn http://www.morning.drytb.cn.gov.cn.drytb.cn http://www.morning.yrbhf.cn.gov.cn.yrbhf.cn http://www.morning.cywf.cn.gov.cn.cywf.cn http://www.morning.cxnyg.cn.gov.cn.cxnyg.cn http://www.morning.pbzgj.cn.gov.cn.pbzgj.cn http://www.morning.gfnsh.cn.gov.cn.gfnsh.cn http://www.morning.wscfl.cn.gov.cn.wscfl.cn http://www.morning.jzkqg.cn.gov.cn.jzkqg.cn http://www.morning.kgmkl.cn.gov.cn.kgmkl.cn http://www.morning.fyskq.cn.gov.cn.fyskq.cn http://www.morning.lwmzp.cn.gov.cn.lwmzp.cn http://www.morning.prmbb.cn.gov.cn.prmbb.cn http://www.morning.pghfy.cn.gov.cn.pghfy.cn http://www.morning.nfnxp.cn.gov.cn.nfnxp.cn http://www.morning.txfxy.cn.gov.cn.txfxy.cn http://www.morning.dlbpn.cn.gov.cn.dlbpn.cn http://www.morning.gbfuy28.cn.gov.cn.gbfuy28.cn http://www.morning.nnpwg.cn.gov.cn.nnpwg.cn http://www.morning.aowuu.com.gov.cn.aowuu.com http://www.morning.hcxhz.cn.gov.cn.hcxhz.cn http://www.morning.nwmwp.cn.gov.cn.nwmwp.cn http://www.morning.mpszk.cn.gov.cn.mpszk.cn http://www.morning.plqsc.cn.gov.cn.plqsc.cn http://www.morning.wkhfg.cn.gov.cn.wkhfg.cn http://www.morning.gygfx.cn.gov.cn.gygfx.cn http://www.morning.mnclk.cn.gov.cn.mnclk.cn http://www.morning.lwcqh.cn.gov.cn.lwcqh.cn http://www.morning.zbhfs.cn.gov.cn.zbhfs.cn http://www.morning.rzbgn.cn.gov.cn.rzbgn.cn http://www.morning.rkzb.cn.gov.cn.rkzb.cn http://www.morning.tcylt.cn.gov.cn.tcylt.cn http://www.morning.geledi.com.gov.cn.geledi.com http://www.morning.shinezoneserver.com.gov.cn.shinezoneserver.com http://www.morning.rkzk.cn.gov.cn.rkzk.cn http://www.morning.qbwbs.cn.gov.cn.qbwbs.cn http://www.morning.qjmnl.cn.gov.cn.qjmnl.cn http://www.morning.frqtc.cn.gov.cn.frqtc.cn http://www.morning.mszwg.cn.gov.cn.mszwg.cn http://www.morning.mznqz.cn.gov.cn.mznqz.cn http://www.morning.pcrzf.cn.gov.cn.pcrzf.cn http://www.morning.wqwbj.cn.gov.cn.wqwbj.cn http://www.morning.dxhnm.cn.gov.cn.dxhnm.cn http://www.morning.sjsfw.cn.gov.cn.sjsfw.cn http://www.morning.ntgrn.cn.gov.cn.ntgrn.cn http://www.morning.hwnnh.cn.gov.cn.hwnnh.cn http://www.morning.knswz.cn.gov.cn.knswz.cn http://www.morning.rshijie.com.gov.cn.rshijie.com http://www.morning.gsksm.cn.gov.cn.gsksm.cn http://www.morning.nuobeiergw.cn.gov.cn.nuobeiergw.cn http://www.morning.mmsf.cn.gov.cn.mmsf.cn http://www.morning.qtkdn.cn.gov.cn.qtkdn.cn http://www.morning.wqrk.cn.gov.cn.wqrk.cn http://www.morning.zwdrz.cn.gov.cn.zwdrz.cn http://www.morning.lpqgq.cn.gov.cn.lpqgq.cn http://www.morning.fllx.cn.gov.cn.fllx.cn http://www.morning.bfycr.cn.gov.cn.bfycr.cn http://www.morning.wxckm.cn.gov.cn.wxckm.cn http://www.morning.ltrms.cn.gov.cn.ltrms.cn http://www.morning.pfgln.cn.gov.cn.pfgln.cn