Python 如何刮除';更多';Quora个人资料页面的一部分?

Python 如何刮除';更多';Quora个人资料页面的一部分?,python,ajax,screen-scraping,web-scraping,Python,Ajax,Screen Scraping,Web Scraping,为了确定Quora上所有主题的列表,我决定先从下面的许多主题开始,例如。我从这个页面上抓取了主题,但是现在我需要从Ajax页面上抓取主题,当您单击页面底部的“更多”按钮时,该页面会被加载。我试图找到在点击“更多”按钮时执行的javascript函数,但还没有找到。以下是html页面中可能相关的三个片段: <div class=\"pager_next action_button\" id=\"__w2_mEaYKRZ_more\">More</div> {\"more_b

为了确定Quora上所有主题的列表,我决定先从下面的许多主题开始,例如。我从这个页面上抓取了主题,但是现在我需要从Ajax页面上抓取主题,当您单击页面底部的“更多”按钮时,该页面会被加载。我试图找到在点击“更多”按钮时执行的javascript函数,但还没有找到。以下是html页面中可能相关的三个片段:

<div class=\"pager_next action_button\" id=\"__w2_mEaYKRZ_more\">More</div>
{\"more_button\": \"mEaYKRZ\"}

\"dPs6zd5\": {\"more_button\": \"more_button\"}

new(PagedListMoreButton)(\"mEaYKRZ\",\"more_button\",{},\"live:ld_c5OMje_9424:cls:a.view.paged_list:PagedListMoreButton:/TW7WZFZNft72w\",{})

您可以在浏览器的dom检查器中的事件侦听器下看到它。这是一个匿名函数,如下所示:

#just prints topics followed by Charlie Cheevers from the 1st page
#!/usr/bin/python
import httplib2,time,re
from BeautifulSoup import BeautifulSoup
SCRAPING_CONN = httplib2.Http(".cache")

def fetch(url,method="GET"):
    return SCRAPING_CONN.request(url,method)

def extractTopic(s):
    d = {}
    d['url'] = "http://www.quora.com" + s['href']
    d['topicName'] = s.findChildren()[0].string
    return d

def fetch_stories():
    page = fetch(u"http://www.quora.com/Charlie-Cheever/topics")
    soup = BeautifulSoup(page[1])
    stories = soup.findAll('a', 'topic_name')
    topics = [extractTopic(s) for s in stories]
    for t in topics:
        print u"%s, %s\n" % (t['topicName'],t['url'])

stories = fetch_stories()
function (){return typeof d!=="undefined"&&!d.event.triggered?d.event.handle.apply(l.elem,arguments):b}

这看起来是一个很难解决的网站,你可以考虑使用Sele.

嗨,阿门洲,我正在做一些类似的事情。你找到解决办法了吗?