I have a script that scrape list of chapter from that website…
- User
I have a script that scrape list of chapter from that website "https://animedaily.net/supreme-magus-novel.html" , the problem is that website does not provide list of chapter one page but the part in page 1 and the next part in page 2 and so on to the end of chapter list I write a code that scrape the chapter but I have issue I want scrape the all the chapter list parts in all the pages how to do that , python code , import requests from bs4 import BeautifulSoup
def scrape_chapters(url): try: # Request the page response = requests.get(url) response.raise_for_status() # Raise an error if the status is not 200
code# Parse the HTML content soup = BeautifulSoup(response.content, 'html.parser') # Locate the specified 'div', then traverse to target 'li' elements chapter_list_items = soup.select( 'div.col-xs-12.light-off-list div.row div ul li' ) # Extracting href and title text for each 'li' for li in chapter_list_items: a_tag = li.find('a') if a_tag: href = a_tag.get('href', '') title_text = a_tag.get('title', '') print(f"Title: {title_text}\nURL: {href}\n") except requests.RequestException as e: print(f"Error fetching the page: {e}")The desired URL for the data
url = "https://animedaily.net/supreme-magus-novel.html" scrape_chapters(url) , html of the pages navigation bar , 12345LastChoose page Go
- Assistant
- User
write a python scrpt that scrape list chapter from that xpath "//div[@class="ch-list"]/p" to erach "p" scrape the title and the href , Chapter 2970 Go deep into the Rebirth Cave, the Stone Forest Field, and the Bloodline Totem Chapter 2969 Arrive at the Cave of Rebirth, a magical place Chapter 2968 Yu Huatian’s trump card, Ye Yu’s harvest, the ancient stars…
- Assistant
To scrape chapter titles and their corresponding URLs using BeautifulSoup in Python from the given HTML structure, you can use the
selectmethod to target the elements using equivalent CSS selectors for the provided XPath. Here's a script that demonstrates how to achieve this: