Last active
May 26, 2022 15:21
-
-
Save mdpabel/681d9bb9ce3e628ea51dac0ae7fe37d5 to your computer and use it in GitHub Desktop.
Get links from https://books.toscrape.com/
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
| import re | |
| import requests | |
| res = requests.get("https://books.toscrape.com/") | |
| pattern = 'href=[\'"](.*?)[\'"]' | |
| links = re.findall(pattern, res.text) | |
| file = open('links.txt', 'w') | |
| for link in links: | |
| file.write(link + "\n") | |
| print('Done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment