mirror of
https://github.com/netzbegruenung/social-spider.git
synced 2024-05-05 04:03:41 +02:00
refactor both scrapers to one file
This commit is contained in:
parent
d80a552ff8
commit
808b2a6641
21
facebook.py
21
facebook.py
|
@ -1,21 +0,0 @@
|
|||
import requests
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def scrape(username):
|
||||
url = "https://www.facebook.com/" + username
|
||||
r = requests.get(url)
|
||||
|
||||
s = str(r.content)
|
||||
|
||||
pattern = "Gefällt ([\d\.]+) Mal"
|
||||
result = re.search(pattern, s)
|
||||
if result:
|
||||
return int(result[1].replace(".", ""))
|
||||
else:
|
||||
print("No data found", file=sys.stderr)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(scrape("GrueneStgt"))
|
|
@ -5,7 +5,7 @@ import re
|
|||
import sys
|
||||
|
||||
|
||||
def scrape(username):
|
||||
def scrapeInstagramData(username):
|
||||
url = "https://www.instagram.com/" + username
|
||||
r = requests.get(url)
|
||||
|
||||
|
@ -22,6 +22,19 @@ def scrape(username):
|
|||
else:
|
||||
print("No data found", file=sys.stderr)
|
||||
|
||||
def scrapeFacebookLikes(username):
|
||||
url = "https://www.facebook.com/" + username
|
||||
r = requests.get(url)
|
||||
|
||||
s = str(r.content)
|
||||
|
||||
pattern = "Gefällt ([\d\.]+) Mal"
|
||||
result = re.search(pattern, s)
|
||||
if result:
|
||||
return int(result[1].replace(".", ""))
|
||||
else:
|
||||
print("No data found", file=sys.stderr)
|
||||
|
||||
if __name__ == '__main__':
|
||||
pprint(scrape("die_gruenen"))
|
||||
pprint(scrapeInstagramData("die_gruenen"))
|
||||
print(scrapeFacebookLikes("B90DieGruenen"))
|
Loading…
Reference in a new issue