Can you wrote me python code for text mining which take comments from Gucci's page…
- User
Can you wrote me python code for text mining which take comments from Gucci's page Instagram page and put in excel file and save the excel file in my desktop?
Assistant
Here is a Python code to scrape comments from Gucci's Instagram page and save them to an Excel file on your desktop:
import requests from bs4 import BeautifulSoup import pandas as pd # Define the Instagram page url url = 'https://www.instagram.com/gucci/' # Get page content page = requests.get(url) # Parse HTML with BeautifulSoup soup = BeautifulSoup(page.content, 'html.parser') # Find all comment sections comment_sections = soup.find_all('div', class_=['_7UhW9']) comments = [] # Extract comments from each section for section in comment_sections: for comment in section.find_all('span', class_=['g47SY']): comments.append(comment.text) # Save comments to a DataFrame df = pd.DataFrame(comments, columns=['Comment']) # Save DataFrame to an Excel file file_path = '/Users/username/Desktop/gucci_comments.xlsx' df.to_excel(file_path, index=False)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.