Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从Reddit中获取标题_Python_Web Scraping - Fatal编程技术网

Python 从Reddit中获取标题

Python 从Reddit中获取标题,python,web-scraping,Python,Web Scraping,在Reddit头版抓住头条新闻的最佳方式是什么?目前,我正在使用BeautifulSoup4尝试删除它们,但使用RedditAPI似乎是一个可行的选择,但我在他们的文档中找不到要点击哪个URL来请求头条新闻。类似于http://www.reddit.com/r/frontpage/top.json?limit=10是我的猜测,但这并没有引起任何新闻标题 Python刮刀方法:(不工作) 有什么建议吗?在@jornsharpe的评论之后,有一个python Reddit API客户端: 用于

在Reddit头版抓住头条新闻的最佳方式是什么?目前,我正在使用
BeautifulSoup4
尝试删除它们,但使用RedditAPI似乎是一个可行的选择,但我在他们的文档中找不到要点击哪个URL来请求头条新闻。类似于
http://www.reddit.com/r/frontpage/top.json?limit=10
是我的猜测,但这并没有引起任何新闻标题

Python刮刀方法:(不工作)


有什么建议吗?

在@jornsharpe的评论之后,有一个python Reddit API客户端:

用于获取头条新闻:

>>> import praw
>>> r = praw.Reddit(user_agent='my_cool_application')
>>> for item in r.get_top():
...     print item
... 
4901 :: I made a Redundant Clock.
4764 :: Elon Musk plans to launch 4,000 satellites to deliver high-speed Inte...
5144 :: Pipeline breach spills up 50,000 gallons of oil into the Yellowstone ...
4603 :: Avalanche Dog In Training
4564 :: TIL it is illegal in many countries to perform surgical procedures on...
...
还有,等等。

你看过了吗?根据这篇文章,它只是
https://www.reddit.com/top.json
。啊,这些都不是我的。使用r.get_front_page()可以获得所需的结果。
>>> import praw
>>> r = praw.Reddit(user_agent='my_cool_application')
>>> for item in r.get_top():
...     print item
... 
4901 :: I made a Redundant Clock.
4764 :: Elon Musk plans to launch 4,000 satellites to deliver high-speed Inte...
5144 :: Pipeline breach spills up 50,000 gallons of oil into the Yellowstone ...
4603 :: Avalanche Dog In Training
4564 :: TIL it is illegal in many countries to perform surgical procedures on...
...