You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
warning: overriding "Cookie" header with :cookies option
But when I use :cookies as headers, my code doesn't work. On the other hand when I use cookies as headers my code works fine.
Below is my code:
require'nokogiri'require'rest-client'classSessiondefinitialize(headers={})@headers=headers@cookies={}@options={verify_ssl: true,# Tambahkan ini jika Anda menghadapi masalah SSLmax_redirects: 5,# Batasan pengalihan maksimumtimeout: 10,# Batas waktu permintaan dalam detikopen_timeout: 5,# Batas waktu koneksi dalam detikuser_agent: 'python-requests/2.28.2',# Ganti dengan User-Agent yang diinginkanfollow_redirect: true}enddefget(url,params={},headers={},options={})request(:get,url,params,headers,nil,options)enddefpost(url,data={},headers={},options={})request(:post,url,{},headers,data,options)enddefput(url,data={},headers={},options={})request(:put,url,{},headers,data,options)enddefdelete(url,headers={},options={})request(:delete,url,{},headers,nil,options)enddefhead(url,headers={},options={})request(:head,url,{},headers,nil,options)endprivatedefrequest(method,url,params={},headers={},data=nil,options={})headers=@headers.merge(headers)headers['Cookie']=@cookies.map{ |k,v| "#{k}=#{v}"}.join('; ')unless@cookies.empty?response=RestClient::Request.execute(method: method,url: url,headers: headers,payload: data,params: params,**@options.merge(options))do |response|
if[301,302,307].include?(response.code)response.follow_redirectionelseresponse.return!endend# Perbarui cookie setelah menerima responsupdate_cookies(response.cookies)responseenddefupdate_cookies(cookie_header)returnifcookie_header.nil? || cookie_header.empty?cookie_header.eachdo |key,value|
@cookies[key]=valueendendendemail="example@example.com"pass="password123"sesi=Session.new({'User-Agent': 'Mozilla/5.0 (Linux; Android 8.1.0; vivo 1802) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Mobile Safari/537.36','Accept': '*/*','Connection': 'keep-alive'})req=sesi.get("https://mbasic.facebook.com")res=Nokogiri::HTML(req.body)data={}res.search('input').each{|i| data.update({i['name']=>i['value']})}data.delete_if{|k,v| (k == "sign_up"ork.nil?)}data.update({"email"=>email,"pass"=>pass})url="https://mbasic.facebook.com#{res.at('form')['action']}"submit=sesi.post(url,data=data)
How to remove the warning message?
The text was updated successfully, but these errors were encountered:
I want to do a post request to a page https://mbasic.facebook.com
But when I do that, a warning pops up
But when I use :cookies as headers, my code doesn't work. On the other hand when I use cookies as headers my code works fine.
Below is my code:
How to remove the warning message?
The text was updated successfully, but these errors were encountered: