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')  # this will return all links+text

4.67
3
Usman 95 points

                                    from bs4 import BeautifulSoup
import requests

response = requests.get('url')
all_links = response.find_all('a')  # this will return all links+text
for link in all_links:
  print(link.get_text())	# this will prints all text
  print(link.get('href'))	# this will print all links

4.67 (3 Votes)
0
4.38
8
Nigel Holt 130 points

                                    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(url)
print(profile_image)

4.38 (8 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source