-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
45 lines (36 loc) · 1.18 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import twint
import time
def scrape_twitter_profile(username):
c = twint.Config()
c.Username = username
c.Store_object = True
c.Hide_output = True
retries = 3
delay = 2
while retries > 0:
try:
twint.run.Lookup(c)
user = twint.output.users_list[0]
# Extract user data
full_name = user.name
bio = user.bio
location = user.location
join_date = user.join_date
# Print the scraped user data
print("Username:", username)
print("Full Name:", full_name)
print("Bio:", bio)
print("Location:", location)
print("Join Date:", join_date)
return
except Exception as e:
print("Failed to retrieve data from the profile.")
print("Error:", str(e))
retries -= 1
if retries > 0:
print("Retrying after", delay, "seconds...")
time.sleep(delay)
delay *= 2
print("Max retries exceeded. Unable to scrape the profile.")
# Scrape user data from the provided Twitter profile
scrape_twitter_profile("LIndustries21")