Created
November 8, 2016 08:34
-
-
Save boffbowsh/be5b64f0136a68314c05480eb776e9cf to your computer and use it in GitHub Desktop.
This file contains 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
from sys import argv | |
from bs4 import BeautifulSoup | |
import requests | |
if __name__ == "__main__": | |
search = requests.get("https://www.gov.uk/api/search.json?q=%s&filter_format%%5B%%5D=answer" % argv[1]) | |
for result in search.json()["results"]: | |
answer = requests.get("https://www.gov.uk%s" % result["link"]) | |
soup = BeautifulSoup(answer.text, 'html.parser') | |
highlight = soup.find_all('div', class_="highlight-answer") | |
if highlight: | |
print result["link"] | |
print highlight[0].text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment