Uname:Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64

Base Dir : /var/www/html

User : gavin


403WebShell
403Webshell
Server IP : 68.183.124.220  /  Your IP : 216.73.217.137
Web Server : Apache/2.4.18 (Ubuntu)
System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64
User : gavin ( 1000)
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/gavin/workspace/comecondo/python/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/gavin/workspace/comecondo/python//extract_property_address.py
import mysql.connector
from bs4 import BeautifulSoup
import requests
import time
import os

config = {
  'user': 'root',
  'password': 'Ilovekitty1',
  'host': '127.0.0.1',
  'database': 'comecondo',
  'raise_on_warnings': True
}

cnx = mysql.connector.connect(host="localhost", user="root", password="Ilovekitty1", database="comecondo")
dbcur = cnx.cursor()
query = "select a.id, b.property_name, b.city, a.post_content from wp_posts a join cc_property_full b where a.id=b.id and a.id not in (select id from cc_property_address) order by a.id;"
dbcur.execute(query)
result = dbcur.fetchall()
print(str(len(result)))

for row in result:
    print('ID  : '+str(row[0]))
    print('Name: '+str(row[1]))
    print('City: '+str(row[2]))
    prop_id, city = str(row[0]), row[2]
    soup = BeautifulSoup(row[3], 'html.parser')
    all_iframe = soup.find_all('iframe')
    for fr in all_iframe:
        if 'aria-label' in str(fr):
            address = fr.get('aria-label').replace("'","")
            print ('Address: '+address)
            if address.endswith(' '):
                print ('Space Error !!')
            http_formatted_address = 'Canada+'+address.replace(' ','+')
            print ('Formated Address: '+http_formatted_address) 
            google_query = 'https://maps.googleapis.com/maps/api/geocode/json?address='+http_formatted_address+'&key=AIzaSyBoXHHlPQF0n8otx2Q0M7I5hmVLxvtcS1Q'
            # Query Latitude and Longitude from Geo
            resp = requests.get(google_query).json()
            print(resp['status'])
            if resp['status']=='OK':
                print(resp['results'][0]['formatted_address'])
                print(resp['results'][0]['geometry']['location'])
                lat = str(resp['results'][0]['geometry']['location']['lat'])
                lng = str(resp['results'][0]['geometry']['location']['lng'])
                query = "insert into cc_property_address (id, address, lat, lng) values ("+prop_id+", '"+address+"', "+lat+", "+lng+");"
                print(query)
                dbcur.execute(query)
                print('')
cnx.commit()
cnx.close()

Youez - 2016 - github.com/yon3zu
LinuXploit