Created
May 28, 2017 17:44
-
-
Save baditaflorin/3d4f9b64c5bda1a75573b4469ba3d765 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import requests | |
from bs4 import BeautifulSoup | |
page = requests.get("http://www.socialbakers.com/statistics/facebook/pages/detail/1196562180359709-leffe-italia") | |
soup = BeautifulSoup(page.content, 'html.parser') | |
if page.status_code == 200: | |
print "response ok" | |
#print(soup.prettify()) | |
fb_account_description = soup.find('div', class_='account').get_text() | |
# for number_of_fans we first extract the part of the post were we have a "li" with class "odd" and then we filter for the "strong". | |
number_of_fans = [a for a in (b.find('strong') | |
for b in soup.findAll('li', class_='odd')) if a] | |
fb_page_link = soup.find('a', class_='blank show-tooltip',href=True) | |
account_tag_list = [a for a in (b.findAll('a') | |
for b in soup.findAll('div', class_='account-tag-list')) if a] | |
for x in account_tag_list: | |
for y in x: | |
print y | |
print account_tag_list | |
#for row in account_tag_list: | |
# col = row.find('data-icons-before') | |
# print col | |
#fb_page_type = account_tag_list.find('data-icons-before') | |
# for link in soup.find_all('a', href=True): | |
# print(link['href']) | |
print fb_account_description | |
print number_of_fans[0] | |
print fb_page_link['href'] | |
#print fb_page_type |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment