Created
April 13, 2019 00:10
-
-
Save Zylvian/8c16c5c3b04ddb8c568798db1968e03c 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
startlink = 'https://onepiece.fandom.com/api.php?format=json&action=query&' | |
test_name = "Monkey D. Luffy" | |
fetch_json = requests.get(startlink + 'generator=allpages&gapfrom=' + test_name + '&prop=info&inprop=url').json() | |
print(fetch_json) | |
# Gets all pages | |
all_pages = fetch_json['query']['pages'] | |
# Gets first page | |
first_page = next(iter(all_pages.values())) | |
# Gets first url | |
first_title = first_page["title"] | |
first_url = first_page["fullurl"] | |
# THIS IS THE URL WE NEED AT LEAST | |
print(first_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment