2024-05-12 20:56:23 发布
网友
我想从不同的搜索引擎为我的python搜索查询获取链接。在
例如
查询:-“谁是Sachin Tendulkar”
输出:想要从谷歌搜索、必应搜索链接。
在挖掘了许多链接后,我找到了谷歌刮刀包。在
谷歌刮刀链接
https://pypi.python.org/pypi/GoogleScraper/0.1.37
但这个包裹我一点运气都没有。有人能帮我用googlescrapler或任何替代scrape link的方法吗
嘿,你可以用你提到的那个包来实现它GoogleScrapler。去吧通过链接https://github.com/NikolaiT/GoogleScraper
下面是python代码
from GoogleScraper import scrape_with_config, GoogleSearchError def saveLink(self, query): # See in the config.cfg file for possible values try: if query: file_name = query.replace(" " , "_") self.config = { 'SCRAPING': { 'use_own_ip': 'True', 'keyword': query, 'search_engines': 'bing', 'num_pages_for_keyword': 1, 'scrape_method': 'http' }, 'SELENIUM': { 'sel_browser': 'chrome', }, 'OUTPUT': { 'output_filename': "path/" + file_name + ".json" }, 'GLOBAL': { 'do_caching': 'False' } } raw_html = "" sqlalchemy_session = scrape_with_config(self.config) except Exception: import traceback print(traceback.format_exc())
如果你想重用多个搜索引擎,你可以添加
“搜索引擎”:“必应、雅虎、谷歌”,
您将在文件output_filename
嘿,你可以用你提到的那个包来实现它GoogleScrapler。去吧通过链接https://github.com/NikolaiT/GoogleScraper
下面是python代码
如果你想重用多个搜索引擎,你可以添加
“搜索引擎”:“必应、雅虎、谷歌”,
您将在文件output_filename
相关问题 更多 >
编程相关推荐