Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
azizkpln
GitHub Repository: azizkpln/moriarty-project
Path: blob/master/Investigation/getComments.py
193 views
1
import requests
2
from bs4 import BeautifulSoup
3
def printAll():
4
return comment
5
def getComments_(phone_number):
6
global comment,comment_
7
comment=[]
8
headers = {
9
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36'
10
}
11
try:
12
phone_number=phone_number.split("+")[1]
13
reqToServer=requests.get(f"https://www.unknownphone.com/phone/{phone_number}",headers=headers)
14
source = BeautifulSoup(reqToServer.content,"lxml")
15
for i in range(1,10):
16
try:
17
comment_=source.select(f'#content > div > main > section.comments > ul > li:nth-child({i}) > article > div')[0].text
18
comment.append(comment_)
19
except:
20
pass
21
if comment==[]:
22
comment_="No comment for this number"
23
comment.append(comment_)
24
except:
25
comment_="No comment for this number"
26
comment.append(comment_)
27
28