我需要从一个会话发送请求,这是python
上的一个示例,但我需要翻译成R
语言。
import requests
import lxml.html
import BeautifulSoup
login = '---'
password = '---'
url = 'http://hh.ru/'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.0; rv:14.0) Gecko/20100101 Firefox/14.0.1',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'ru-ru,ru;q=0.8,en-us;q=0.5,en;q=0.3',
'Accept-Encoding': 'gzip, deflate',
'Connection': 'keep-alive',
'DNT': '1'
}
session = requests.session()
data = session.get(url, headers=headers).content
page = lxml.html.fromstring(data)
form = page.forms[3]
form.fields['username'] = login
form.fields['password'] = password
response = session.post(form.action, data=form.form_values())
link= "http://hh.ru/search/resume?area=1&clusters=true&text=xxx&pos=full_text&logic=normal&exp_period=all_time"
data2 = session.get(link, headers=headers).text