-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from Juhibhojani/main
Adding Whatsapp get_profile_info Bot
- Loading branch information
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.common.by import By | ||
from selenium.webdriver.common.keys import Keys | ||
import time | ||
from bs4 import BeautifulSoup | ||
|
||
try: | ||
# Initialize the Chrome WebDriver | ||
driver = webdriver.Chrome() | ||
|
||
# Open the WhatsApp Web URL | ||
driver.get("https://web.whatsapp.com/") | ||
|
||
# Prompt the user to scan the QR code manually | ||
print("Scan QR Code") | ||
|
||
# Wait for the user to scan the QR code manually for 60 seconds | ||
time.sleep(60) | ||
|
||
print("Enter name of person") | ||
person = input() | ||
time.sleep(2) | ||
# XPath for the search input field | ||
inp_xpath_search = "//p[@class='selectable-text copyable-text iq0m558w g0rxnol2']" | ||
search_input = driver.find_element(By.XPATH, inp_xpath_search) | ||
|
||
# Set the value and trigger events | ||
search_input.clear() | ||
search_input.send_keys(person) | ||
search_input.send_keys(Keys.RETURN) | ||
time.sleep(5) | ||
|
||
# Click on the user profile | ||
profile = driver.find_element(By.XPATH, "//div[@class='_2au8k']") | ||
profile.click() | ||
time.sleep(10) | ||
|
||
# Get the page source and parse it using BeautifulSoup | ||
html = driver.page_source | ||
soup = BeautifulSoup(html, "html.parser") | ||
|
||
# Find the container element | ||
container = soup.find( | ||
"div", {"class": "lhggkp7q qq0sjtgm ebjesfe0 jxacihee tkdu00h0"} | ||
) | ||
|
||
# Find and print the user's name | ||
name = container.find("h2") | ||
print("User's Name:", name.text) | ||
|
||
# Find and print the user's number | ||
number = container.find("div", {"class": "a4ywakfo qt60bha0"}) | ||
print("User's Number:", number.text) | ||
|
||
# Find and print the top groups the user is in, if any | ||
groups = container.find("div", {"class": "_3YS_f _2A1R8"}) | ||
if groups is not None: | ||
print("Top Groups:") | ||
group = [] | ||
for items in groups: | ||
group.append(items.find("div", {"class": "y_sn4"}).text) | ||
print(group) | ||
else: | ||
print("No group's in common") | ||
|
||
# Find and print any common interests or details | ||
about = container.find( | ||
"span", {"class": "cw3vfol9 _11JPr selectable-text copyable-text"} | ||
) | ||
if about: | ||
print("About:", about.text) | ||
else: | ||
print("No About") | ||
|
||
# Close the WebDriver | ||
driver.quit() | ||
except Exception as e: | ||
print("Exception Occured:", e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# WhatsApp Web Get-Profile-Information Bot | ||
|
||
Automate the process of retrieving profile information of an individual on WhatsApp using this Python script. This script utilizes the Selenium library to interact with WhatsApp Web and extract user information. | ||
|
||
## Installation | ||
|
||
1. Ensure you have Python installed on your system. | ||
2. Clone this repository or download the provided code: | ||
|
||
```bash | ||
git clone https://github.com/neelshah2409/Bot-Collection.git | ||
``` | ||
|
||
3. Navigate to the project directory: | ||
|
||
```bash | ||
cd Whatsapp-bot/Profile-Info-bot | ||
``` | ||
4. Install the required dependencies: | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
5. Download the [ChromeDriver](https://chromedriver.chromium.org/downloads) suitable for your Chrome version and place it in the project directory. | ||
|
||
## Usage | ||
|
||
1. Make sure you have a compatible version of Chrome installed on your system. | ||
2. Run the script: | ||
|
||
```bash | ||
python Whatsapp.py | ||
``` | ||
3. A Chrome browser window will open, displaying WhatsApp Web. | ||
4. Scan the QR code using your phone to log in to WhatsApp Web. | ||
5. Upon successful login, the script will wait for 60 seconds to load the page. | ||
6. When prompted, provide the name of the individual whose profile information you want to retrieve. | ||
7. The script will print the retrieved information on the terminal. | ||
|
||
## Notes | ||
|
||
- This script uses the Chrome WebDriver for Selenium automation. Ensure that the `chromedriver` executable matches your Chrome browser version and is located in the project directory. | ||
- The script waits for 60 seconds to ensure proper loading of the WhatsApp Web page before interaction. You can modify this delay if necessary. | ||
|
||
## Contributor | ||
|
||
- [Juhi Bhojani](https://github.com/Juhibhojani) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
selenium==3.141.0 |