ulixee / hero

The web browser built for scraping
MIT License
647 stars 32 forks source link

Ability to set network responses #237

Closed FoonkG closed 11 months ago

FoonkG commented 11 months ago

Added ability to intercept certain requests by matching url (string | RegExp). Body, statusCode and headers can be manipulated.

Feature for #236

blakebyrnes commented 11 months ago

Thanks for the PR! I have a few questions about what the intended use is for when you ONLY set headers. Seems we can also simplify the handler logic (and need to simply injected new items for any intercepted resources). It will automatically match on the urls for you, so you're just providing the handler when it matches.

pashkasan commented 11 months ago

nice one, for sure better to return full response or some function handler

FoonkG commented 11 months ago

@blakebyrnes I didn't think the option for ONLY setting headers through. I only really need changing of the body for my issue and i thought adding the possibility for changing headers and statuscode would be an extra. I don't need this and so if it's quicker, i can remove the headers and statuscode part and leave it to somebody else. I need a release of this feature as soon as possible for my project.

FoonkG commented 11 months ago

@blakebyrnes Comitted the changes

blakebyrnes commented 11 months ago

Closes #236