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

奥地利网站后缀dw制作网页用的模板

奥地利网站后缀,dw制作网页用的模板,设计素材app,深圳做网站好的公司本项目纯学习使用。 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.yayakq.cn/news/638270/

相关文章:

  • 聊城手机网站建设服务广州网络营销推广公司
  • 北京网站开发品牌wordpress 自己写
  • dw做网站首页长宽设置多少软件大全下载app免费
  • 厦门网站建设优化企业高级ppt模板免费下载
  • 做物流网站费用多少南通网络推广公司
  • 广州多语言外贸网站建设网站建设论坛社区
  • 网站建设工程师是做什么的哈尔滨专业建网站哪家好
  • 网站建设中山做网站公司 衡阳公司
  • 微信公众号是在哪个网站做的企业展厅设计哪里好
  • 门户网站建设需要多少钱深圳市梵品品牌设计有限公司
  • 秦皇岛建设网站公司哪家好asp网站开发教程
  • 头条网站怎么做的wordpress评论置顶
  • 素材网站定制建设网站站点有哪些步骤
  • 社交网站开发技术岗网站内容收录
  • html5做网站导航小型工作室项目大全
  • 佛山网站建设服务网站建设用户分析
  • 智能模板网站建设哪家好给公司做网站销售怎样啦
  • 聊城做网站的公司信息杭州网站建设企业
  • 芜湖企业网站建设wordpress图片过大
  • 常用的网站类型有哪些类型有哪些类型有哪些郑州学校网站建设
  • 北京市保障房建设投资中心网站瘫痪怎么叫人做网站
  • 成都住房和城乡建设局网站做网站外包的公司好干嘛
  • 网站开发下载那个课程商城网站模板
  • 公司做网站需要多少钱铁路建设标准网站
  • 设计师网站资源济南网站建设哪家好
  • 网站设计师发展方向山东饰品行业网站制作
  • 有没类似建设通的免费网站视频号的链接在哪
  • 盗网站后台源码龙海网站建设价格
  • 珠海市横琴新区建设环保局网站站长工具百度百科
  • 网站开发上传视频教程自己制作网址收款