russiangram_requests.py (854B)
1 from urllib import request, parse 2 from .russiangram_parser import RussiangramParser 3 4 def stressmark(s): 5 data = { '__VIEWSTATE': '/wEPDwUKMTMzOTA3OTU5N2Rk5MNrzf8M72AYC/+c+xWZbzp8Td8=', 6 '__VIEWSTATEGENERATOR': 'CA0B0334', 7 '__EVENTTARGET': '', 8 '__EVENTARGUMENT': '', 9 '__EVENTVALIDATION': '/wEdAAMDOEAYUxkPEDCURzqp69xETjsDcGH04u5hS3jwIIl38e/d1Dv61Nm9xfklcqY855XV2JJyoBPZpaGFe8T+7UtRw3M4iA==', 10 'ctl00$MainContent$UserSentenceTextbox': s, 11 'ctl00$MainContent$SubmitButton': 'Annotate'} 12 13 request_url = "https://russiangram.com/" 14 encoded_data = parse.urlencode(data).encode() 15 req = request.Request(request_url, data=encoded_data) 16 resp = request.urlopen(req) 17 body = resp.read() 18 19 rgparser = RussiangramParser() 20 rgparser.feed(str(body)) 21 return rgparser.data