import requests,json
class requests_webdriver:
def init(self):
self.driver = self.chorme_driver()
def chorme_driver(self):
url = "http://127.0.0.1:4444/wd/hub/session"
data = json.dumps({
“desiredCapabiliyies”:{
“browserName”:“chrome”
}
})
res = requests.post(url,data).json()
session = res["sessionId"]
driver = url + session
return driver
def get_url(self,url):
base_url = self.driver+"/url"
data =json.dumps({
"url":url
})
requests.post(base_url,data)
if name == “__main”:
requests_driver = requests_webdriver()
requests_driver.get_url(“http://www.baidu.com”)