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="&#123;&quot;tn&quot;:&quot;k&quot;&#125;">     <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

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -