google新闻提要的python客户端。

gnfetcher的Python项目详细描述


PyPIlicense

gnfetcher

一个易于使用的python客户端,用于Google News feeds

gnfetcher支持python 2和python 3。

安装

要安装gnfetcher,只需,

$ pip install gnfetcher

要安装并使用gnfetcher cli,请按照以下说明进行操作 CLI

过滤器

google新闻提要使用3个基本过滤器:

  • edition将结果限制为特定版本。还有更多 超过70种不同语言的地区版谷歌新闻。 每一个版本都是专门为观众量身定制的新闻。
  • topic将结果限制为特定主题。有几个 自定义主题,如体育、商业、世界、健康、科学, 政治等
  • location将结果限制在特定位置。

除此之外,您还可以指定:

  • language提供指定语言的结果。60多种语言 得到支持。
  • query根据特定查询提供结果。

使用量

  • 创建gnfetcher对象:

    >>>fromgnfetcherimportgnfetcher>>>client=gnfetcher()
  • 获取当前参数设置

    >>>client.get_config(){'edition':'United States (English)','language':'english','loaction':None,'query':None,'topic':'top stories'}
  • 获取新闻源

    >>>client.get_news()[{'img':'https://t1.gstatic.com/images?q=tbn:ANd9GcQ5KFdYdQclmxUdvdV2zYQ_hO7JMrG2864ZDdN9A3GxORmTf_issciogLEEZmA5QIFfRQsyYDlm','link':'https://www.washingtonpost.com/world/french-citizens-vote-in-an-uncertain-race-that-could-determine-europes-future/2017/04/23/fd3759ce-1fa4-11e7-bb59-a74ccaf1d02f_story.html','title':"French citizens vote in an uncertain race that could determine Europe's future - Washington Post"},{'img':'https://t0.gstatic.com/images?q=tbn:ANd9GcTfosRmEfpoH40YiX5dyEIgL5rw-OSgcsKGEYhIm15f-OVQmWoidnH5NZD6P1vwaZfpQ33Xt8tZ','link':'https://www.washingtonpost.com/national/health-science/big-turnout-expected-for-march-for-science-in-dc/2017/04/21/67cf7f90-237f-11e7-bb9d-8cd6118e1409_story.html','title':"Why people are marching for science: 'There is no Planet B' - Washington Post"},{'img':'https://t2.gstatic.com/images?q=tbn:ANd9GcRw4xGtSrL5ZCpDkp5QHLUBPLgDNCsFFpgjJeOdD2q4w4giPDsDf9G3NOAZeNYWOf8f5V1aYTLu','link':'https://www.washingtonpost.com/politics/nearing-100-days-trumps-approval-at-record-lows-but-his-base-is-holding/2017/04/22/a513a466-26b4-11e7-b503-9d616bd5a305_story.html','title':"Nearing 100 days, Trump's approval at record lows but his base is holding - Washington Post"}]
  • 更改参数

    >>>client.edition='India (Hindi)'>>>client.topic='sports'>>>client.language='hindi'>>>client.get_news()[{'img':'https://t0.gstatic.com/images?q=tbn:ANd9GcTSo3cJx_-NKmtcsAaB8ZNC6tVF-FzU7FxLMmT9GwETYw-h_XmgzE_Ux2Bz3e2dk_iRUsaCIwbY','link':'http://aajtak.intoday.in/sports/story/ms-dhoni-is-the-captain-of-shane-warnes-all-time-ipl-eleven-1-925107.html','title':'वॉर्न की IPL टीम में भारतीयों का बोलबाला, धोनी को सौंपी कप्तानी - आज तक'},{'img':'https://t1.gstatic.com/images?q=tbn:ANd9GcTlK3tT02bbryKfJS_l-fbICNHDUFsaXktMQSnvg_Pi-TWMBknuvBL3OhViOGzhjOcMtig4pg3t','link':'http://www.patrika.com/news/kanpur/jwala-gutta-says-up-government-should-make-strategy-for-better-sports-hindi-news-1560241/','title':'प्यार का करारनामा, इंटरनेशनल बैडमिंटन प्लेयर ज्वाला गुट्टा के हाथ पर नजर आया! - Patrika'}]
  • 通过查询获取新闻

    >>>client.query='cricket'>>>client.get_news()[{'img':'https://t2.gstatic.com/images?q=tbn:ANd9GcTQ6zOoooNhFaXM7bdl2WmmuJkHdE5ED26Mp2QtaRyKELMlBuvc62LmDVgt7-D3m7mgIPGI4vXf','link':'http://www.espncricinfo.com/west-indies-v-pakistan-2017/content/story/1094080.html','title':'West Indies v Pakistan, 1st Test, Kingston, 2nd day April 22, 2017 - ESPNcricinfo.com'},{'img':'https://t1.gstatic.com/images?q=tbn:ANd9GcRePCUSgV_AXDrzSe59DsO7j6tgdcfWWocnusHc4OtLxNtGNloVuh_HPA1BtibucOTO9r-qwtNL','link':'https://thefield.scroll.in/835391/cricket-china-bowled-out-for-28-in-world-league-qualifier','title':'Cricket: China bowled out for 28 in World League qualifier - Scroll.in'},{'img':'https://t2.gstatic.com/images?q=tbn:ANd9GcSpVMJHsdo6Q5SxuIzwrBHn7seXis3zwryH5ohRyeLVZj3phQDX1e92HZqW7iODBeJM7mrGf7yH','link':'http://www.hindustantimes.com/ipl-2017/live-cricket-score-ipl-2017-t20-mumbai-indians-vs-delhi-daredevils-live/story-CLQVOWa9v8ub7clUSz41LN.html','title':'Full Cricket Score, IPL 2017, T20, Mumbai Indians vs Delhi Daredevils: MI beat DD by 14 runs - Hindustan Times'}]
  • 按位置获取新闻

    >>>client.loaction='delhi'>>>client.get_news()[{'img':'https://t3.gstatic.com/images?q=tbn:ANd9GcQI4mXbCB-bLvuiCqN1BoAyClMWgllzHy8DG9SCNDr3_dH9JpNpgfqTz8UneHeE85jdi0wknyhF','link':'http://timesofindia.indiatimes.com/city/delhi/cops-wrap-city-in-a-multi-layer-security-blanket/articleshow/58305944.cms','title':'MCD polls: Cops wrap Delhi in multi-layer security blanket - Times of India'},{'img':'https://t0.gstatic.com/images?q=tbn:ANd9GcTd-gOZQ59kAj-GJ9uEHQ3wbGMF6Y4dI9pkc2B9RI0YyOrBPB4jIljR5zFFRXlB0KjqcuZxkAVl','link':'http://www.financialexpress.com/india-news/mcd-polls-2017-heritage-not-on-any-partys-agenda/637968/','title':"MCD polls 2017: Heritage not on any party's agenda - Financial Express"},{'img':'https://t1.gstatic.com/images?q=tbn:ANd9GcRK_YvCPtCF1uiA8aKz3LJLPHFP7zAlPHFkotuxL7Jr8DZBnA-w5HfMCe1Q69J7Cpf_AKKsNKeV','link':'http://timesofindia.indiatimes.com/city/delhi/car-owner-booked-for-kashmere-gate-accident/articleshow/58308236.cms','title':'Car owner booked for Kashmere Gate accident - Times of India - Times of India'}]
  • 获取可用版本、语言和主题的列表

    >>>client.editions['Germany','Poland','Morocco','Colombia','India (Telugu)','Australia','Hungary','India (Malayalam)','United Arab Emirates','Lebanon','Serbia','Canada (English)','China','United States (English)','Nigeria','Austria','Kenya','Peru','Italy','Ghana','Ukraine (Russian)','Belgium (French)','Vietnam','South Africa','Ethiopia','Lithuania','Philippines','Brazil','Saudi Arabia','India (Hindi)','India (Tamil)','United States (Spanish)','Latvia','Singapore','Norway','Sweden','Canada (French)','Egypt','Japan','Arab world','Ukraine (Ukranian)','Netherlands','Hong Kong','Romania','United Kingdom','Slovakia','Czech Republic','Chile','Indonesia','France','Bangladesh','Taiwan','Tanzania','Argentina','Greece','Mexico','Pakistan','Bulgaria','Senegal','Zimbabwe','Belgium (Dutch)','Uganda','Turkey','Portugal','Slovenia','Namibia','Cuba','New Zealand','Russia','India (English)','Botswana','Venezuela','Israel (Hebrew)','Thailand','Switzerland','Israel (English)','Ireland','Malaysia']>>>client.topics['business','politics','top stories','technology','world','sports','entertainment','national']>>>client.languages['tamil','kannada','norwegian','swedish','bulgarian','arabic','hindi','catalan','georgian','latvian','albanian','japanese','english','german','lithuanian','chinese simplified','polish','czech','macedonian','yiddish','turkish','dutch','urdu','serbian','basque','thai','hungarian','danish','galician','latin','chinese traditional','vietnamese','portuguese','welsh','croatian','bengali','finnish','icelandic','azerbaijani','swahili','malay','korean','slovak','russian','irish','spanish','belarusian','french','estonian','indonesian','slovenian','italian','maltese','haitian creole','esperanto','ukrainian','afrikaans','filipino','gujarati','hebrew','telugu','greek','persian','romanian']

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java为扫描器的输入生成字符序列   hibernate中的java实体合并   如何使变量在Java文件中成为全局变量   java JVM崩溃“异常访问冲突”   向MediaMetadataRetriever中的setDataSource()发送Uri时发生java IllegalArgumentException   java没有节约协议?   用户界面java gui帮助actionlistener   java索引越界异常,即使大小小于索引?   在C++中使用java的困惑   在普通java编码中插入图像   JDBC上的java缓存数据   在Java中,在字符串的特定位置替换子字符串   java在运行elasticsearch集群时遇到Perm Gen空间问题   java Soap故障跟踪   java拆分器。固定长度(int)。拆分(字符串)   java获取jar内部包的路径