Skip to content

Instantly share code, notes, and snippets.

@salgo60
Created October 12, 2019 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salgo60/11e92c50327a2ff2a6cf50253bd3da6b to your computer and use it in GitHub Desktop.
Save salgo60/11e92c50327a2ff2a6cf50253bd3da6b to your computer and use it in GitHub Desktop.
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
url = 'http://makthavare.se/2018/09/19/kartlaggning-har-ar-riksdagsledamoterna-pa-twitter-2/'
response = requests.get(url)
soup = BeautifulSoup(response.text, "html.parser")
soup.findAll('a')
one_a_tag = soup.findAll('a')[36]
link = one_a_tag['href']
time.sleep(1)
for i in range(1,len(soup.findAll('a'))):
one_a_tag = soup.findAll('a')[i]
if "twitter.com" in one_a_tag['href']:
print( one_a_tag.text,",",one_a_tag['href'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment