Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how list ul li with python scraping

# importing the modules
import requests
from bs4 import BeautifulSoup
  
# providing url
url = "https://auth.geeksforgeeks.org/user/adityaprasad1308/articles"
  
# creating requests object
html = requests.get(url).content
  
# creating soup object
data = BeautifulSoup(html, 'html.parser')
  
# finding parent <ul> tag
parent = data.find("body").find("ul")
  
# finding all <li> tags
text = list(parent.descendants)
  
# printing the content in <li> tag
print(text)
for i in range(2, len(text), 2):
    print(text[i], end=" ")
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #list #ul #li #python #scraping
ADD COMMENT
Topic
Name
7+2 =