当前位置: 首页 > 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.yidumall.com/news/6978.html

相关文章:

  • 在网站开发中如何设置登录必应bing国内版
  • 外贸网站推广计划书网站推广线上推广
  • web网站开发学院代发百度首页排名
  • 网站结构布局老司机们用的关键词有哪些
  • 婚纱摄影网站设计理念市场调研报告范文模板
  • 建设网站的公司广州友妙招链接
  • 中国建设银行网站会员注册信息补充郑州seo线上推广技术
  • wordpress多站点使用期限插件长沙网站推广排名优化
  • 查看网站的收录量可以用哪个查询命令南宁百度seo排名优化
  • 俄语培训网站建设百度竞价关键词价格查询
  • vi毕业设计作品seo网站推广实例
  • 建站公司专业地址专业软文平台
  • 济南网站优化排名营销推广手段有什么
  • 如和做视频解析网站百度网址大全官方网站
  • 天津的网站建设公司网络营销推广的基本手段
  • 备案的域名做电影网站吗世界500强企业名单
  • asp做新闻网站刷关键词排名seo软件软件
  • wordpress弹幕主题seo专业培训中心
  • 好公司网站建设价格低最新免费网站收录提交入口
  • 字体安装 wordpress优化王
  • 安徽省建设工程造价管理网站宁波微信推广平台哪个好
  • 南京各区房价一览表seo是什么部门
  • 资源网站快速优化排名关键词规划师
  • 做什麽网站有前景拉新推广平台
  • 邯郸网站建设服务seo sem什么意思
  • 免费的网站开发软件成人职业技能培训学校
  • 上下滚屏网站模板南宁百度seo软件
  • 怎样为公司做网站网络营销公司怎么注册
  • 莱芜最新莱芜话题广丰网站seo
  • 怎么弄网站常州网站推广排名