how to get all links text from a website python beautifulsoup code example
Example 1: how to get all links from a website python beautifulsoup
from bs4 import BeautifulSoup
import requests
response = requests.get('url')
all_links = response.find_all('a')
Example 2: how to get all links text from a website python beautifulsoup
from bs4 import BeautifulSoup
import requests
response = requests.get('url')
all_links = response.find_all('a')
for link in all_links:
print(link.get_text())
print(link.get('href'))
Example 3: how to get all links text from a website python beautifulsoup
import requests
from bs4 import BeautifulSoup as bs
github_avatar = input('Input git user: ')
url = 'https://github.com/'+ github_avatar
r = requests.get(url)
soup = bs(r.text, 'html.parser')
profile_image = soup.find('img', {'alt' : 'Avatar'})['src']
print(profile_image)