sayem314 / hooman

http interceptor to hoomanize cloudflare requests
https://www.npmjs.com/package/hooman
MIT License
148 stars 18 forks source link

Pass header as an option? #13

Closed Billy2011 closed 4 years ago

Billy2011 commented 4 years ago

What would you like to discuss?

I want to use hooman with Python. Unfortunately I have little experience with JS and at the moment, I don't think it is possible to pass header (user agent, cookie, ...) to hooman. It would be nice if that were possible in the future.

Checklist

sayem314 commented 4 years ago

Please read docs of https://github.com/sindresorhus/got/blob/master/readme.md, hooman is a wrapper around got.

hooman(url, {
    headers: {
        'user-agent': 'my_user_agent'
    }
});
Billy2011 commented 4 years ago

I've tried it, but it doesn't work:

const got = require("hooman");

const url = "http://example.com";
const cookie = "myCookie=myValue";
const agent = "My-User-Agent";

got(url, {
    header: {
        'User-Agent': agent,
        'Cookie': cookie
        }
  })
  .then(response => {
    console.log('Header--->>>', response.request.options.headers)
  })
  .catch(error => {
    console.error(error);
  });

Header--->>> {
  'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36',
  'cache-control': 'max-age=0',
  'upgrade-insecure-requests': '1',
  'accept-encoding': 'gzip, deflate, br',
  origin: 'http://example.com',
  referer: 'http://example.com/'
}
sayem314 commented 4 years ago

It's not header, it's headers. Please triple check your spelling.

Billy2011 commented 4 years ago

What a shit, it's hard to recognize your own mistakes, I'm sorry;)

sayem314 commented 4 years ago

No problem.