Last active
August 25, 2020 17:06
-
-
Save tioxy/3376def6bbe5440cb4b22bb732fe6697 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import requests | |
import json | |
from bs4 import BeautifulSoup | |
from datetime import datetime | |
def GetWeightKG(string): | |
weight = "" | |
for i in range(0,len(string)): | |
if(string[i] == "("): | |
x = 1 | |
while(x<3): | |
weight += string[i+x] | |
x += 1 | |
break | |
return int(weight) | |
def GetHeightM(string): | |
height = "" | |
for i in range(0,len(string)): | |
if(string[i] == "("): | |
height = string[i+1:i+4] | |
return int(height) | |
name = input("Type the Pornstar Name: ") | |
person = name.lower() | |
person = person.replace(" ","-") | |
r = requests.get("http://www.pornhub.com/pornstar/{0}".format(person)) | |
soup = BeautifulSoup(r.content,"lxml") | |
soup.prettify() | |
bio = soup.find_all("div",{"itemprop":"description"})[0].string | |
height = soup.find_all("span",{"itemprop":"height"})[0].string | |
weight = soup.find_all("span",{"itemprop":"weight"})[0].string | |
birthPlace = soup.find_all("span",{"itemprop":"birthPlace"})[0].string | |
birthData = soup.find_all("span",{"itemprop":"birthDate"})[0].string | |
age = int(datetime.now().year) - int(birthData[0:4]) | |
birthData = "{0}/{1}/{2}".format(birthData[8:12],birthData[5:7],birthData[0:4]) | |
jsonData = {"name": name, "heightCM": GetHeightM(height), "weightKG": GetWeightKG(weight), "birthplace" : birthPlace, "birthdata" : birthData, "age" : age, "bio" : bio} | |
jsonToPython = json.dumps(jsonData) | |
with open('pornstar.json', 'w') as outfile: | |
json.dump(jsonData, outfile) | |
print("JSON file saved together with this .py file.") | |
print("JSON: \n" + jsonToPython) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment