#!/usr/bin/env python # -*- coding: utf-8 -*- """ 作者:昨夜星辰 脚本作用:伪装浏览器根据经纬度解析地理位置 创建时间:2017-01-11 """ import re import requests lat = ‘23.0300000000‘ lng = ‘113.7500000000‘ url = ‘http://www.gpsspg.com/apis/maps/geo/‘ ‘?output=jsonp&lat=%s&lng=%s‘ ‘&type=0&callback=jQuery110208922237625713032_1484117544079&_=1484117544080‘ % (lat, lng) headers = { "Accept": "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01", "Accept-Encoding": "gzip, deflate, sdch", "Accept-Language": "zh-CN,zh;q=0.8", "Cache-Control": "no-cache", "Connection": "keep-alive", "Cookie": "ARRAffinity=1c4bb86219260370ca02426fc1018822e09cba1fb72ab3da662d6370f9142231;" "Hm_lvt_15b1a40a8d25f43208adae1c1e12a514=1484097427,1484117457;" "Hm_lpvt_15b1a40a8d25f43208adae1c1e12a514=1484117548;AJSTAT_ok_pages=5;AJSTAT_ok_times=2", "Host": "www.gpsspg.com", "Pragma": "no-cache", "Referer": "http", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)" "Chrome/55.0.2883.87 Safari/537.36", "X-Requested-With": "XMLHttpRequest", } text = requests.get(url, headers=headers).text print re.search(r‘"address":"(.*?)"‘, text).group(1)
时间: 2024-11-08 20:13:16