Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to srape all links from a website in python

# importing the HTMLSession class
from requests_html import HTMLSession
# create the object of the session
session = HTMLSession()
# url of the page
web_page = 'https://www.trtworld.com/'
# making get request to the webpage
respone = session.get(web_page)
# getting the html of the page
page_html = respone.html
# finding all <a> tags
all_links= page_html.links
# extracting meta tags html
for tag in all_links:
    print(tag)

# getting only absolute links
absolute_links = page_html.absolute_links
for abs_link in absolute_links:
    print(abs_link)Copy Code
Source by www.alixaprodev.com #
 
PREVIOUS NEXT
Tagged: #How #srape #links #website #python
ADD COMMENT
Topic
Name
6+5 =