from grab import Grab import json cookies with open cookie json as js

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
from grab import Grab
import json
cookies = {}
with open('cookie.json') as js:
for cookie in json.loads(js.read()):
cookies[cookie["name"]] = cookie["value"]
g = Grab()
g.setup(cookies = cookies)
g.go('https://market.yandex.ru')
print g.doc.select("//span[@class='user__name']").text()