mirror of
https://github.com/timberjoegithub/GoogleScrape.git
synced 2026-07-22 00:19:48 +00:00
Linting
This commit is contained in:
@@ -121,15 +121,15 @@ def preload():
|
|||||||
file=pathlib.Path("./config/joeteststeele_uuid_and_cookie.json")
|
file=pathlib.Path("./config/joeteststeele_uuid_and_cookie.json")
|
||||||
if pathlib.Path.exists(file):
|
if pathlib.Path.exists(file):
|
||||||
pathlib.Path.unlink(file)
|
pathlib.Path.unlink(file)
|
||||||
today = datetime.today().strftime('%Y-%m-%d')
|
# today = datetime.today().strftime('%Y-%m-%d')
|
||||||
return
|
return
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
def clearlist (list):
|
def clearlist (my_list):
|
||||||
for listelement in list:
|
for listelement in my_list:
|
||||||
listelement.clear
|
listelement.clear
|
||||||
return list
|
return my_list
|
||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
@@ -232,19 +232,19 @@ def get_twitter_conn_v2(api_key, api_secret, access_token, access_token_secret)
|
|||||||
|
|
||||||
##################################################################################################
|
##################################################################################################
|
||||||
|
|
||||||
def get_hastags (address, name, type):
|
def get_hastags (address, name, hashtype):
|
||||||
nameNoSpaces = re.sub( r'[^a-zA-Z]','',name)
|
nameNoSpaces = re.sub( r'[^a-zA-Z]','',name)
|
||||||
addressdict = address.rsplit(r' ',3)
|
addressdict = address.rsplit(r' ',3)
|
||||||
zip = addressdict[3]
|
zip_code = addressdict[3]
|
||||||
state = addressdict[2]
|
state = addressdict[2]
|
||||||
city = re.sub( r'[^a-zA-Z]','',addressdict[1])
|
city = re.sub( r'[^a-zA-Z]','',addressdict[1])
|
||||||
if 'short' in type:
|
if 'short' in hashtype:
|
||||||
defaulttags = '#'+nameNoSpaces+' #foodie #food #joeeatswhat @timberjoe'
|
defaulttags = '#'+nameNoSpaces+' #foodie #food #joeeatswhat @timberjoe'
|
||||||
else:
|
else:
|
||||||
defaulttags = "\n\n\n#"+nameNoSpaces+" #foodie #music #food #travel #drinks #instagood #feedme #joeeatswhat @timberjoe"
|
defaulttags = "\n\n\n#"+nameNoSpaces+" #foodie #music #food #travel #drinks #instagood #feedme #joeeatswhat @timberjoe"
|
||||||
citytag = "#"+city
|
citytag = "#"+city
|
||||||
statetag = "#"+state
|
statetag = "#"+state
|
||||||
ziptag = "#"+zip
|
ziptag = "#"+zip_code
|
||||||
if statetag == 'FL':
|
if statetag == 'FL':
|
||||||
statetag += ' #Florida'
|
statetag += ' #Florida'
|
||||||
fulltag = defaulttags+" "+citytag+" "+statetag+" "+ziptag
|
fulltag = defaulttags+" "+citytag+" "+statetag+" "+ziptag
|
||||||
@@ -307,10 +307,7 @@ def post_facebook_video(group_id, video_path,auth_token,title, content, date, ra
|
|||||||
url = f"https://graph-video.facebook.com/{group_id}/videos?access_token=" + auth_token
|
url = f"https://graph-video.facebook.com/{group_id}/videos?access_token=" + auth_token
|
||||||
files={}
|
files={}
|
||||||
addresshtml = re.sub(" ", ".",address)
|
addresshtml = re.sub(" ", ".",address)
|
||||||
#args={}
|
|
||||||
#data["message"]=title + "\n"+address+"\n\n"+ content + "\n"+rating+"\n"+date
|
|
||||||
for eachfile in video_path:
|
for eachfile in video_path:
|
||||||
# my_dict['key'].append(1)
|
|
||||||
files.update({eachfile: open(eachfile, 'rb')})
|
files.update({eachfile: open(eachfile, 'rb')})
|
||||||
data = { "title":title,"description" : title + "\n"+ address+"\nGoogle map to destination: "
|
data = { "title":title,"description" : title + "\n"+ address+"\nGoogle map to destination: "
|
||||||
r"https://www.google.com/maps/dir/?api=1&destination="+addresshtml +"\n\n"+ content +
|
r"https://www.google.com/maps/dir/?api=1&destination="+addresshtml +"\n\n"+ content +
|
||||||
@@ -374,8 +371,8 @@ def get_google_data(driver,outputs ):
|
|||||||
# > span.kvMYJc
|
# > span.kvMYJc
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
score = "Unknown"
|
score = "Unknown"
|
||||||
|
print ('Error: ',error)
|
||||||
more_specific_pics = data.find_elements(By.CLASS_NAME, 'Tya61d')
|
more_specific_pics = data.find_elements(By.CLASS_NAME, 'Tya61d')
|
||||||
|
|
||||||
# Grab more info from google maps entry on this particular review
|
# Grab more info from google maps entry on this particular review
|
||||||
if outputs['postssession'].query(Posts).filter(Posts.name == name,Posts.google != 1) or env.forcegoogleupdate:
|
if outputs['postssession'].query(Posts).filter(Posts.name == name,Posts.google != 1) or env.forcegoogleupdate:
|
||||||
gmaps = googlemaps.Client(env.googleapipass)
|
gmaps = googlemaps.Client(env.googleapipass)
|
||||||
@@ -387,11 +384,11 @@ def get_google_data(driver,outputs ):
|
|||||||
# Get place details
|
# Get place details
|
||||||
# googledetails = gmaps.place(place_id)
|
# googledetails = gmaps.place(place_id)
|
||||||
try:
|
try:
|
||||||
businessurl = (details['result']['website'])
|
businessurl = details['result']['website']
|
||||||
latitude = (details['result']['geometry']['location']['lat'])
|
latitude = details['result']['geometry']['location']['lat']
|
||||||
longitude = (details['result']['geometry']['location']['lng'])
|
longitude = details['result']['geometry']['location']['lng']
|
||||||
pluscode = (details['result']['plus_code']['compound_code'])
|
pluscode = details['result']['plus_code']['compound_code']
|
||||||
googleurl = (details['result']['url'])
|
googleurl = details['result']['url']
|
||||||
database_update_row(name,"businessurl",businessurl,"onlyempty",outputs)
|
database_update_row(name,"businessurl",businessurl,"onlyempty",outputs)
|
||||||
database_update_row(name,"latitude",latitude,"onlyempty",outputs)
|
database_update_row(name,"latitude",latitude,"onlyempty",outputs)
|
||||||
database_update_row(name,"longitude",longitude,"onlyempty",outputs)
|
database_update_row(name,"longitude",longitude,"onlyempty",outputs)
|
||||||
@@ -1342,7 +1339,7 @@ def process_reviews(outputs):
|
|||||||
print (' Facebook: Skipping posting for ',processrow[1].value,' previously written')
|
print (' Facebook: Skipping posting for ',processrow[1].value,' previously written')
|
||||||
if env.xtwitter:
|
if env.xtwitter:
|
||||||
#if writtento["xtwitter"] == 0:
|
#if writtento["xtwitter"] == 0:
|
||||||
# if Posts.query.filter(Posts.name.xtwitter.op('!=')(1)).first()
|
# # if Posts.query.filter(Posts.name.xtwitter.op('!=')(1)).first()
|
||||||
if outputs['postssession'].query(Posts).filter(Posts.name == processrow[1].value,Posts.xtwitter != 1):
|
if outputs['postssession'].query(Posts).filter(Posts.name == processrow[1].value,Posts.xtwitter != 1):
|
||||||
if xtwittercount < env.postsperrun:
|
if xtwittercount < env.postsperrun:
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user