python网页抓取gnp包 [英] python web scraping gnp package

查看:37
本文介绍了python网页抓取gnp包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了页面.基于它,我编写了以下代码.代码运行.我想要一些额外的结果.您可以提出任何建议或替代方案吗?我正在创建 word1,因为我想搜索eric bledsoe"/bigram 而不是 (eric",bledsoe")

I came across the page. Based upon it i wrote the below code. The code runs. I want some additional results. Any suggestions or alternate package that you can suggest? I am creating word1 because i want to search for "eric bledsoe"/bigram and not ("eric","bledsoe")

import gnp
word= 'eric bledsoe'
word1='"' + word + '"'
c = gnp.get_google_news_query(word1)
#c = gnp.get_google_news_query("What's happening on earth")
print (c)

  1. 我如何获得时间戳(6 小时前,2016 年 4 月 25 日等)是与每个新闻相关联?
  2. 如何限制过去 365 天内发布的新闻?
  3. 如何只选取前 x 个条目?例如我想看顶部仅 1000 个结果?我如何浏览 2,3,4....google 新闻页面?

推荐答案

你不能.您使用的软件包不支持任何这些内容.

You can't. The package you're using doesn't support any of those things.

一般来说,我建议您避免使用该软件包.它本质上很脆弱,因为它基于抓取 Google 新闻的 HTML 输出,而不是使用任何官方(甚至非官方!)API,如果 Google 重新设计他们的新闻界面,它很可能会崩溃.

Generally speaking, I'd advise you avoid using that package. It's inherently fragile, as it's based on scraping the HTML output of Google News, rather than using any sort of official (or even unofficial!) API, and is likely to break if Google ever redesigns their News interface.

这篇关于python网页抓取gnp包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆