Path: blob/master/Investigation/getComments.py
193 views
import requests1from bs4 import BeautifulSoup2def printAll():3return comment4def getComments_(phone_number):5global comment,comment_6comment=[]7headers = {8'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'9}10try:11phone_number=phone_number.split("+")[1]12reqToServer=requests.get(f"https://www.unknownphone.com/phone/{phone_number}",headers=headers)13source = BeautifulSoup(reqToServer.content,"lxml")14for i in range(1,10):15try:16comment_=source.select(f'#content > div > main > section.comments > ul > li:nth-child({i}) > article > div')[0].text17comment.append(comment_)18except:19pass20if comment==[]:21comment_="No comment for this number"22comment.append(comment_)23except:24comment_="No comment for this number"25comment.append(comment_)262728