mirror of
https://github.com/timberjoegithub/GoogleScrape.git
synced 2026-07-22 00:19:48 +00:00
update
This commit is contained in:
@@ -92,6 +92,7 @@ class Posts(Base):
|
|||||||
tiktok = sqlalchemy.Column(sqlalchemy.Boolean, default=False)
|
tiktok = sqlalchemy.Column(sqlalchemy.Boolean, default=False)
|
||||||
#active = sqlalchemy.Column(sqlalchemy.Boolean, default=True)
|
#active = sqlalchemy.Column(sqlalchemy.Boolean, default=True)
|
||||||
place_id = sqlalchemy.Column(sqlalchemy.String(length=126, collation="utf8"))
|
place_id = sqlalchemy.Column(sqlalchemy.String(length=126, collation="utf8"))
|
||||||
|
review_id = sqlalchemy.Column(sqlalchemy.String(length=126, collation="utf8"))
|
||||||
googledetails = sqlalchemy.Column(sqlalchemy.String(length=4096, collation="utf8"))
|
googledetails = sqlalchemy.Column(sqlalchemy.String(length=4096, collation="utf8"))
|
||||||
#businessurl = sqlalchemy.Column(sqlalchemy.String(length=512, collation="utf8"))
|
#businessurl = sqlalchemy.Column(sqlalchemy.String(length=512, collation="utf8"))
|
||||||
pluscode = sqlalchemy.Column(sqlalchemy.String(length=64, collation="utf8"))
|
pluscode = sqlalchemy.Column(sqlalchemy.String(length=64, collation="utf8"))
|
||||||
@@ -876,18 +877,18 @@ def check_wordpress_post(postname, postdate, headers2,local_outputs):
|
|||||||
except AttributeError as error:
|
except AttributeError as error:
|
||||||
print ('Could not query for post on wordpress: ', postname,postdate, type(error))
|
print ('Could not query for post on wordpress: ', postname,postdate, type(error))
|
||||||
return False, False
|
return False, False
|
||||||
try:
|
# try:
|
||||||
if result[0]['visitdate']:
|
# newdate,newdate2,visitdate = get_wordpress_post_date_string(result[0]['date'],result[0]['date'])
|
||||||
print ('Post exists, checking visit date')
|
# newdate3,newdate4,visitdate2 = get_wordpress_post_date_string(postdate,str(datetime.now()))
|
||||||
except KeyError as error:
|
# if visitdate and visitdate2:
|
||||||
print (' Post exists but does not have post date in visitdate field:',error)
|
# print ('Post exists, checking visit date')
|
||||||
database_update_row(postname,"visitdate",postdate,"forceall",local_outputs)
|
# except KeyError as error:
|
||||||
response2 = requests.get(env.wpAPI+"/posts?search="+postname, headers=headers2,\
|
# print (' Post exists but does not have post date in visitdate field:',error)
|
||||||
timeout=env.request_timeout)
|
if len(result) > 0:
|
||||||
|
d1list = result[0]['date'].split("-")
|
||||||
result = response2.json()
|
d2list = postdate.split("-")
|
||||||
if len(result) > 0 and postdate == result[0]['visitdate']:
|
if d1list[0] == d2list[0] and d1list[1] == d2list[1]:
|
||||||
return int(result[0]['id']), result[0]['link']
|
return int(result[0]['id']), result[0]['link']
|
||||||
print(' -No existing post with same name: ' + postname)
|
print(' -No existing post with same name: ' + postname)
|
||||||
return False, False
|
return False, False
|
||||||
|
|
||||||
@@ -1377,7 +1378,7 @@ def post_to_wordpress(title,content,headers,date,rating,address,picslist,local_o
|
|||||||
newdate2 = dateparts[0]+'-'+dateparts[1]+'-'+dateparts2[0]+'T22:00:00'
|
newdate2 = dateparts[0]+'-'+dateparts[1]+'-'+dateparts2[0]+'T22:00:00'
|
||||||
#newdate2 = str(re.sub(r'-','/',str(newdate.date())))+'T22:00:00'
|
#newdate2 = str(re.sub(r'-','/',str(newdate.date())))+'T22:00:00'
|
||||||
print (' Got Date: ', newdate2, newdate)
|
print (' Got Date: ', newdate2, newdate)
|
||||||
post_id, post_link = check_wordpress_post(title,visitdate,headers,local_outputs)
|
post_id, post_link = check_wordpress_post(title,newdate2,headers,local_outputs)
|
||||||
featured_photo_id = get_wordpress_featured_photo_id(post_id)
|
featured_photo_id = get_wordpress_featured_photo_id(post_id)
|
||||||
print(f" Featured photo ID: for {title} post {post_id} is: {featured_photo_id}")
|
print(f" Featured photo ID: for {title} post {post_id} is: {featured_photo_id}")
|
||||||
if env.block_google_maps is not True:
|
if env.block_google_maps is not True:
|
||||||
@@ -1394,6 +1395,7 @@ def post_to_wordpress(title,content,headers,date,rating,address,picslist,local_o
|
|||||||
"content": googleadress+'\n\n'+content+'\n'+rating ,
|
"content": googleadress+'\n\n'+content+'\n'+rating ,
|
||||||
"status": "publish", # Set to 'draft' if you want to save as a draft
|
"status": "publish", # Set to 'draft' if you want to save as a draft
|
||||||
"date": newdate2,
|
"date": newdate2,
|
||||||
|
"meta": {'visitdate':visitdate}
|
||||||
# "date": str(newdate)+'T22:00:00',
|
# "date": str(newdate)+'T22:00:00',
|
||||||
# "author":"joesteele"
|
# "author":"joesteele"
|
||||||
}
|
}
|
||||||
@@ -1876,7 +1878,7 @@ def post_to_wordpress2(title,content,headers,date,rating,address,picslist,local_
|
|||||||
# formatting = '%b/%Y/%d'
|
# formatting = '%b/%Y/%d'
|
||||||
date_string = date
|
date_string = date
|
||||||
newdate,newdate2,visitdate = get_wordpress_post_date_string(date_string,date)
|
newdate,newdate2,visitdate = get_wordpress_post_date_string(date_string,date)
|
||||||
post_id, post_link = check_wordpress_post(title,visitdate,headers,local_outputs)
|
post_id, post_link = check_wordpress_post(title,newdate2,headers,local_outputs)
|
||||||
if picslist and picslist != '':
|
if picslist and picslist != '':
|
||||||
content_pics = build_picslist(picchop,picslist,file_id)
|
content_pics = build_picslist(picchop,picslist,file_id)
|
||||||
featured_photo_id = get_wordpress_featured_photo_id(post_id)
|
featured_photo_id = get_wordpress_featured_photo_id(post_id)
|
||||||
@@ -2001,9 +2003,11 @@ def process_reviews2(outputs):
|
|||||||
if env.web and processrow.web is False or env.force_web_create is True:
|
if env.web and processrow.web is False or env.force_web_create is True:
|
||||||
#if writtento["web"] == 0 :
|
#if writtento["web"] == 0 :
|
||||||
try:
|
try:
|
||||||
# post_id, post_link = get_wordpress_post_id_and_link(processrow.name,\
|
#date_string = date
|
||||||
post_id, post_link = check_wordpress_post(processrow.name,processrow.visitdate,outputs['web'],outputs)
|
#newdate,newdate2,visitdate = get_wordpress_post_date_string(date_string,date)
|
||||||
# outputs['web'] )
|
post_id, post_link = get_wordpress_post_id_and_link(processrow.name,\
|
||||||
|
outputs['web'] )
|
||||||
|
# post_id, post_link = check_wordpress_post(processrow.name,processrow.date,outputs['web'],outputs)
|
||||||
if env.forcegoogleupdate is True and env.block_google_maps is not True:
|
if env.forcegoogleupdate is True and env.block_google_maps is not True:
|
||||||
if post_link:
|
if post_link:
|
||||||
database_update_row(processrow.name,"wpurl",post_link,"forceall"\
|
database_update_row(processrow.name,"wpurl",post_link,"forceall"\
|
||||||
|
|||||||
Reference in New Issue
Block a user