def GenContent(address,what):
return urllib.urlopen("http://www.yelp.com/search?find_desc="+what+"&#find_loc="+address).read()
I am using python to do this.
It works prefectly in my browser.
def GenContent(address,what):
return urllib.urlopen("http://www.yelp.com/search?find_desc="+what+"&#find_loc="+address).read()
I am using python to do this.
It works prefectly in my browser.
I posted this in two fourms, python and webdev
What is your question ?
Is there a way to make it not be like this?
It works perfectly in my browser.
I did it the hard way, I used this:
import win32api
import win32con
import win32com
import ctypes
import webbrowser
import time
import os
import shutil
SendInput = ctypes.windll.user32.SendInput
# C struct redefinitions
PUL = ctypes.POINTER(ctypes.c_ulong)
class KeyBdInput(ctypes.Structure):
_fields_ = [("wVk", ctypes.c_ushort),
("wScan", ctypes.c_ushort),
("dwFlags", ctypes.c_ulong),
("time", ctypes.c_ulong),
("dwExtraInfo", PUL)]
class HardwareInput(ctypes.Structure):
_fields_ = [("uMsg", ctypes.c_ulong),
("wParamL", ctypes.c_short),
("wParamH", ctypes.c_ushort)]
class MouseInput(ctypes.Structure):
_fields_ = [("dx", ctypes.c_long),
("dy", ctypes.c_long),
("mouseData", ctypes.c_ulong),
("dwFlags", ctypes.c_ulong),
("time",ctypes.c_ulong),
("dwExtraInfo", PUL)]
class Input_I(ctypes.Union):
_fields_ = [("ki", KeyBdInput),
("mi", MouseInput),
("hi", HardwareInput)]
class Input(ctypes.Structure):
_fields_ = [("type", ctypes.c_ulong),
("ii", Input_I)]
# Actuals Functions
def PressKey(hexKeyCode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput( hexKeyCode, 0x48, 0, 0, ctypes.pointer(extra) )
x = Input( ctypes.c_ulong(1), ii_ )
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
def ReleaseKey(hexKeyCode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput( hexKeyCode, 0x48, 0x0002, 0, ctypes.pointer(extra) )
x = Input( ctypes.c_ulong(1), ii_ )
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
def PressEnter():
PressKey(0xD)
ReleaseKey(0x0D)
def GetContent(l,googlechrome=True):
webbrowser.open(l)
time.sleep(1.5)
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
def rightclick(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,x,y,0,0)
rightclick(100,100)
time.sleep(.5)
click(220, 191)
time.sleep(2.5)
PressEnter()
time.sleep(3.5)
for i in os.listdir("C:/Users/James/Desktop/"):
if i.endswith(".htm") or i.endswith(".html"):
url = i
break
r = open(url).read()
os.remove(url)
if googlechrome:
try:
shutil.rmtree(url+"_files")
except:
pass
return r
you need pywin32
What was the original problem? Your method reminds me of Visual Basic's "SendKey()". If downloading and writing an html page to disk was the problem, it can be easily solved in python.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.