Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add User-Agent support #201

Closed
lucumt opened this issue Aug 25, 2017 · 2 comments
Closed

Add User-Agent support #201

lucumt opened this issue Aug 25, 2017 · 2 comments

Comments

@lucumt
Copy link

lucumt commented Aug 25, 2017

I found there is a same issue,but it was closed and not solved,so I want to recreate a new issue.

Sometimes gocrawl do not meet our requirements and we need to use goquery to parse and fetch data,if we use goquery to frequently,it may be blocked by the website,so user-agent configuration is necessary.
Do you have any plan to implement it?

If you do not plan to add this function, can you provide us some useful suggest for how can we add user-agent or proxy when we invoke the method below
doc, err := goquery.NewDocument(url)
Thanks a lot

@mna
Copy link
Member

mna commented Aug 25, 2017

Hello,

As mentioned in #173 , NewDocument(url) is just a helper function that should not have been added in the first place. Goquery is not concerned with how you get the html, it is about manipulating this html.

To set the user-agent, the same recommendation I made in the issue you linked still stands - use Go's stdlib (or any other network request package) to make the request - with full support to set user-agent and anything you want about the request, and once you get a response you're happy with, pass it to NewDocumentFromReader.

Martin

@lucumt
Copy link
Author

lucumt commented Aug 26, 2017

@mna Thank you very much,I got it and will close these issue

@lucumt lucumt closed this as completed Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants