Skip to content

This Python script interacts with Bing Chat, performs searches using provided queries, and scrapes the responses. It then writes the scraped responses back to a Google Sheet. The script utilizes Selenium and BeautifulSoup libraries for web scraping and gspread library for interacting with Google Sheets.

Notifications You must be signed in to change notification settings

Chichtou/bingchat_Scraper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bingchat_Scraper

This Python script interacts with Bing Chat, performs searches using provided queries, and scrapes the responses. It then writes the scraped responses back to a Google Sheet. The script utilizes Selenium and BeautifulSoup libraries for web scraping and gspread library for interacting with Google Sheets.

Prerequisites Before running the script, you need to install the required libraries. You can install them using the following command:

pip install gspread oauth2client selenium beautifulsoup4

Additionally, you should have the appropriate web driver for Microsoft Edge installed and available in your system's PATH. In this code, we are using the Edge web driver. Make sure to replace it with the appropriate web driver for your browser if you wish to use a different one.

Instructions Ensure you have Python and the required libraries installed. Install the appropriate web driver for Microsoft Edge (or another browser if you modify the script). Create a Google Sheets service account and download the "credentials.json" file. This file should contain the necessary credentials to access your Google Sheets. Share the Google Sheets document with the service account email address. Replace the URL of the Google Sheets document in the main() function with your own document URL. Execute the script. Code Explanation The script is divided into several functions:

-search_bing(query): This function interacts with Bing Chat and performs a search using the provided query. It returns the HTML source of the Bing Chat page after the search.

-parse_response(html): This function takes the HTML source of the Bing Chat page as input and extracts the chat responses from it using BeautifulSoup. It returns the scraped responses as a single string.

-authenticate_google_sheets(): This function authenticates the script with Google Sheets using the "credentials.json" file. It returns the Google Sheets client object.

-main(): The main function of the script. It authenticates with Google Sheets, reads search queries from the specified Google Sheet, performs searches on Bing Chat for each query, scrapes the responses, and writes them back to the Google Sheet in the adjacent column.

Running the Script To run the script, execute it from the command line or through your preferred Python development environment.

python script_name.py

Please replace script_name.py with the actual name of your Python script containing the provided code.

Make sure to wait for the script to finish before checking the Google Sheet for the scraped responses.

Note: This README assumes basic familiarity with Python, Google Sheets, and web scraping using Selenium and BeautifulSoup. If you encounter any issues, refer to the documentation of the respective libraries for troubleshooting.

About

This Python script interacts with Bing Chat, performs searches using provided queries, and scrapes the responses. It then writes the scraped responses back to a Google Sheet. The script utilizes Selenium and BeautifulSoup libraries for web scraping and gspread library for interacting with Google Sheets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages