当前位置: 首页 > news >正文

开封网站建设培训学校关键词的选取原则

开封网站建设培训学校,关键词的选取原则,网络推广引流软件,临沭县建设局官方网站本项目纯学习使用。 1 scrapy 代码 爬取逻辑非常简单,根据url来处理翻页,然后获取到详情页面的链接,再去爬取详情页面的内容即可,最终数据落地到excel中。 经测试,总计获取 11299条中医药材数据。 import pandas as…

本项目纯学习使用。

1 scrapy 代码

爬取逻辑非常简单,根据url来处理翻页,然后获取到详情页面的链接,再去爬取详情页面的内容即可,最终数据落地到excel中。
经测试,总计获取 11299条中医药材数据。

import pandas as pd
import scrapyclass ZhongyaoSpider(scrapy.Spider):name = "zhongyao"start_urls = [f"https://www.zysj.com.cn/zhongyaocai/index__{i}.html" for i in range(1, 27)]def __init__(self, *args, **kwargs):self.data = []def parse(self, response):for li in response.css('div#list-content ul li'):a_tag = li.css('a')title = a_tag.css('::attr(title)').get()href = a_tag.css('::attr(href)').get()if title and href:# 构建完整的详情页 URLdetail_url = response.urljoin(href)yield scrapy.Request(detail_url, callback=self.parse_detail, meta={'title': title})# 解析逻辑def parse_detail(self, response):title = response.meta['title']pinyin = response.css('div.item.pinyin_name_phonetic div.item-content::text').get(default='').strip()alias = response.css('div.item.alias div.item-content p::text').get(default='').strip()english_name = response.css('div.item.english_name div.item-content::text').get(default='').strip()source = response.css('div.item.alias div.item-content p::text').get(default='').strip()# 性味flavor = response.css('div.item.flavor div.item-content p::text').get(default='').strip()functional_indications = response.css('div.item.flavor div.item-content p::text').get(default='').strip()usage = response.css('div.item.usage div.item-content p::text').get(default='').strip()excerpt = response.css('div.item.excerpt div.item-content::text').get(default='').strip()#habitat = response.css('div.item.habitat div.item-content p::text').get(default='').strip()# 出处provenance = response.css('div.item.provenance div.item-content p::text').get(default='').strip()# 性状shape_properties = response.css('div.item.shape_properties div.item-content p::text').get(default='').strip()# 归经attribution = response.css('div.item.attribution div.item-content p::text').get(default='').strip()#  原形态prototype = response.css('div.item.prototype div.item-content p::text').get(default='').strip()# 名家论述discuss = response.css('div.item.discuss div.item-content p::text').get(default='').strip()# 化学成分chemical_composition = response.css('div.item.chemical_composition div.item-content p::text').get(default='').strip()item = {'title': title,'pinyin': pinyin,'alias': alias,'source': source,'english_name': english_name,'habitat': habitat,'flavor': flavor,'functional_indications': functional_indications,'usage': usage,'excerpt': excerpt,'provenance': provenance,'shape_properties': shape_properties,'attribution':  attribution,'prototype': prototype,'discuss': discuss,'chemical_composition': chemical_composition,}self.data.append(item)yield itemdef closed(self, reason):# 当爬虫关闭时,保存数据到 Excel 文件df = pd.DataFrame(self.data)df.to_excel('zhongyao_data.xlsx', index=False)

2 爬取截图

在这里插入图片描述

3 爬取数据截图

在这里插入图片描述

http://www.zhongyajixie.com/news/54080.html

相关文章:

  • 安徽省水利建设厅官方网站手机端竞价恶意点击
  • 苏州外贸网站制作东莞seo建站哪家好
  • 江苏景禾瑜博建设工程有限公司网站惠州seo代理计费
  • 江门做网站的公司济南新站seo外包
  • 商务网站建设毕业设计百度推广seo
  • 宝安做棋牌网站建设找哪家公司好微商引流一般用什么软件
  • 视频网站是用什么框架做的网络营销专业学校排名
  • bi网站开发营销策划与运营团队
  • 自己学做网站网站关键词优化方法
  • 深圳网站建设选哪家好站长工具国色天香
  • 35互联做网站怎么样平台搭建
  • 模板网站下载夫唯seo怎么样
  • 做一个论坛网站多少钱赣州seo外包怎么收费
  • 手机能建网站不seo产品优化推广
  • 最牛的网站建设深圳关键词排名推广
  • 哪个网站做线上家教比较好服装品牌营销策划方案
  • 做资源网站 文件能存储到云盘吗域名网
  • 网站制作一般收费seo优化范畴
  • 我的世界怎么做神器官方网站做任务赚佣金的正规平台
  • 企业网站的开发背景合肥网络公司seo
  • 做折扣的网站有哪些巢湖网站制作
  • 兼职做网站访问量和数据长沙seo男团
  • 网站问责建设书百度软件中心
  • 做网贷中介网站赚钱吗怎么建立网站快捷方式
  • 网站备案后更换主机免费域名注册服务网站
  • 自己的网站做一些诱惑百度网页版网址
  • 网站为什么不收录小红书seo是什么意思
  • 局域网站建设模版微信怎么推广
  • 常德网站制作建设黄页网站推广
  • 中央两学一做专题网站seo流量排行榜神器