Answer the question
In order to leave comments, you need to log in
How to enter username and password programmatically?
There is this code:
#coding:utf-8
import wx
import sys
import time
import cefpython
class MainFrame(wx.Frame):
browser = None
def __init__(self):
wx.Frame.__init__(self, parent=None, id=wx.ID_ANY, title='wxPython example', size=(1000,800))
self.browser = cefpython.CreateBrowser(self.GetHandle(), browserSettings={}, navigateURL="http://ru.grepolis.com")
class MyApp(wx.App):
timer = None
timerID = 1
def OnInit(self):
cefpython.Initialize()
sys.excepthook = cefpython.ExceptHook
self.timer = wx.Timer(self, self.timerID)
self.timer.Start(10) # 10ms
wx.EVT_TIMER(self, self.timerID, self.OnTimer)
frame = MainFrame()
self.SetTopWindow(frame)
frame.Show()
return True
def OnTimer(self, event):
cefpython.SingleMessageLoop()
app = MyApp()
app.MainLoop()
Answer the question
In order to leave comments, you need to log in
The login and password are transmitted by the form either via POST (most often) or via GET.
It is enough to see which fields are passed during login and pass the same ones in the script.
Specifically, with cefpython, I won’t tell you how to do this, but, for example, try using navigateURL.
Although, if you look at the cefpython documentation, it was cool to use SendKeyEvent, SendMouseClickEvent and something like that, but the module is still quite raw and such chips have not yet been made there.
Are there people here who know JavaScript? I need help only in this matter ... How to programmatically enter data and click two buttons ... Is it really necessary to learn all JavaScript because of this, I, so to speak, only know Python for half a year ... I still have to study and study here ...
There are other options: watin, watir, watij. Well, this is if python and javascript are not the only possible option for you
Please help someone sort this out.
Created HTML with text string for example:
code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title>Textovoe Pole</title>
</head>
<body>
<form action="/cgi-bin/handler.cgi">
<p><b>Text</b></p>
<p><input type="text" maxlength="25" size="20"></p>
</form>
</body>
</html>
# Simple CEF Python application,
# for more advanced features see "cefadvanced.py"
import cefpython
import cefwindow
import win32con
import win32gui
import win32api
import sys
import os
def CloseApplication(windowID, message, wparam, lparam):
browser = cefpython.GetBrowserByWindowID(windowID)
browser.CloseBrowser()
return win32gui.DefWindowProc(windowID, message, wparam, lparam)
def QuitApplication(windowID, message, wparam, lparam):
win32gui.PostQuitMessage(0)
return 0
def CefSimple():
sys.excepthook = cefpython.ExceptHook
cefpython.Initialize()
wndproc = {
win32con.WM_CLOSE: CloseApplication,
win32con.WM_DESTROY: QuitApplication,
win32con.WM_SIZE: cefpython.wm_Size,
win32con.WM_SETFOCUS: cefpython.wm_SetFocus,
win32con.WM_ERASEBKGND: cefpython.wm_EraseBkgnd
}
windowID = cefwindow.CreateWindow(title="CefSimple", className="cefsimple",
width=800, height=600, icon="icon.ico", windowProc=wndproc)
browser = cefpython.CreateBrowser(windowID, browserSettings={}, navigateURL="new_2.html")
cefpython.MessageLoop()
cefpython.Shutdown()
if __name__ == "__main__":
CefSimple()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question