Parse public facebook posts with beautifulsoup / python -
i try parse facebook posts made specific topic (like company or product). example posts here https://www.facebook.com/search/latest/?q=facebook
i can login facebook (with python) correctly , able source code of page contains posts looking for. after manual code review found out wanted following:
<div class="_5pbx usercontent" data-ft="{"tn":"k"}"> <p>here text of post need </p> </div>
so started beautifulsoup , following code:
soup = beautifulsoup(pagesourcecode.content, 'html.parser') msg in soup.find_all('div'): print (msg.get('class')
as result ...
[u'hidden_elem']
does have experience in scraping facebook posts? need myself , education purposes
following code should work
soup = beautifulsoup(pagesourcecode.content, 'html.parser') divs = soup.find_all('div', class_="_5pbx usercontent") div in divs: p = div.find('p') print(p.get_text())
Comments
Post a Comment