from distutils . filelist import findall
from unicodedata import name
from xml . be . ElementPath import findtext
from bs4 import BeautifulSoup
import pandas as pd
import requests
import os


url =( ' https://play.google.com/store/search?q=vibrator%20apps&c=apps ' )
source = requests . get ( url )

soup = BeautifulSoup ( source.text , ' html.parser ' )
single = soup . find ( 'div' , class_ = " fUEl2e " )

data = {

'Question' : [ "" ],
'A' : [ "" ],
}
df = pd . DataFrame ( data )
df . to_csv ( '/Users/jitendersingh/Documents/test.csv' , mode = 'a' , index = False , header = True )
print ( "sheet created successfully." )

sheet = pd . read_csv ( '/Users/jitendersingh/Documents/test.csv' , squeeze = True , usecols =[ "Question" , "A" ])

delete = sheet . drop ( sheet.index [ [ 0 ]], axis = 0 , inplace = True ) #delete first row
save = sheet . to_csv ( '/Users/jitendersingh/Documents/test2.csv' ) #save file but index also deletes
bones . remove ( '/Users/jitendersingh/Documents/test.csv' )
link2 = pd . read_csv ( '/Users/jitendersingh/Documents/test2.csv' , squeeze = True , usecols =[ "Question" , "A" ]) #again open file for correct index
save = link2 . to_csv ( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
bones . remove ( '/Users/jitendersingh/Documents/test2.csv' )
print ( sheet )



for singles in single :
mylist = singles . find ( 'a' , class_ = "Si6A0c Gy4nib" )[ 'href' ]
myappname = singles . find ( 'div' , class_ = "ubGTjb" ) . text
data = {

'Question' : [ myappname + ":- " ],
'To' : [ "https://play.google.com" + mylist + "" ],
}
df = pd . DataFrame ( data )
df . to_csv ( '/Users/jitendersingh/Documents/test.csv' , mode = 'a' , index = True , header = False )
print ( "Data appended successfully." )


link = pd . read_csv ( '/Users/jitendersingh/Documents/test.csv' , nrows = 10 , squeeze = True , usecols =[ "Question" , "A" ])
# new = link.reset_index() # add index in new file / try to run this code when upload new file
save = link . to_csv ( '/Users/jitendersingh/Documents/test.csv' ) #save file with correct index
appurl = link . loc [ 0 , 'Question' ]
tabname = link . loc [ 0 , 'A' ]


appsource = requests . get ( appurl )
finder = BeautifulSoup ( appsource.text , ' html.parser ' )

myname = finder . find ( 'h1' , class_ = "Fd93Bb F5UCq p5VxAd" ).span. text
myrating = finder . find ( 'div' , class_ = " TT9eCd " ). text
mydown = finder . find_all ( 'div' , class_ = "ClM7O" )[ 1 ].text
mylogo = finder . find_all ( 'div' , class_ = "Mqg6jb Mhrnjf" )

for logo in mylogo :
finallogo = logo.find ( 'img' , class_ = 'T75of nm4vBd arM4bb' )[ "src" ] #Picture

myss = finder . find_all ( 'div' , class_ = "ULeU3b Utde2e" )

for ss in myss :
newss = ss.find ( 'img' , class_ = 'T75of B5GQxf' )[ "src" ] #Picture
newss2 = newss.replace ( "=w526-h296" , "" )
ssdata = {

'Link' : [ newss2 ],
'Status' : [ "hello" ],
}
df = pd . DataFrame ( ssdata )
df . to_csv ( '/Users/jitendersingh/Documents/ss.csv' , mode = 'a' , index = False , header = False )
print ( "ss file created successfully." )


0 comments:

Post a Comment

 
Top