Jun-14-2023, 05:28 PM
(This post was last modified: Jun-14-2023, 06:11 PM by snippsat.
Edit Reason: Fix code tag
)
Hello all! Can anyone help me?
I want to scrape all books of French language and export them to excel or csv. what i'm doing wrong?
I want to scrape all books of French language and export them to excel or csv. what i'm doing wrong?
from bs4 import BeautifulSoup import requests import pandas as pd def get_data(url): response = requests.get(url) soup = BeautifulSoup(response.text, "lxml") books = soup.find_all("div", class_="widgetYordamListe animated fadeInUp") data = [] for book in books: item = {} item["Title"] = book.find("span", class_="badge badge-light").text[1:] item["Code"] = book.find("span", class_="context").text[1:] data.append(item) return data def export_data(data): df = pd.DataFrame(data) df.to_excel("fr.xlsx") df.to_csv("fr.csv") if __name__ == "__main__": data = get_data("http://85.105.31.188/yordambt/yordam.php?dIstekTuru=sAramaListe&aDil=fr") export_data(data) print ("Done.")