python - 如何从 xpath 中抓取企业名称并在 csv 中获取文件
问题描述
i am trying to scrape yellow page by using scrapy and python getting all other result right but not getting the business name
尝试更改 xpath 甚至尝试了 css 选择器但没有得到正确的结果
解决方案
如果您谈论的是 yellowpages.com,那么您可以使用带有以下标签的 css 选择器从搜索结果页面中抓取企业名称:'div.info .business-name span::text'
因此,例如,您可以启动一个 scrapy shell 并转到搜索结果:
scrapy shell "https://www.yellowpages.com/search?search_terms=doctors&geo_location_terms=berlin"
然后在你的scrapy shell中输入以下内容:
response.css('div.info .business-name span::text').extract()
您现在应该会收到该特定页面的所有公司名称的列表。
但是请注意,yellowpages.com 在他们的 robots.txt 中明确声明他们的任何页面都不允许使用scrapy。
推荐阅读
- java - 如何解决 org.hibernate.PropertyValueException
- dart - 未为类型“String”定义运算符“[]=”
- scala - Zio-Kafka:为主题生成消息
- python - 在python中将json文件与comon键合并
- javascript - 对象 PDF 查看器无法在 chrome 中呈现超过 2.0 MB 的大文件
- javascript - 在不使用 js 中的 shift/unshift/loop 的情况下从数组的开头添加或删除
- postgresql - 如何在关系数据库中对版本控制用例进行数据建模
- java - 如何正确覆盖 java.io.Closeable 中的 close() 方法来杀死一个对象?
- flutter - Flutter - 如何通过 enough_mail 回复邮件
- java - 任务 ':app:packageDebug' 执行失败。> 预期的文件集合只包含一个文件,但是,它包含多个文件