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

Configurable scraper user agent string #409

Merged
merged 6 commits into from
Mar 20, 2020

Conversation

WithoutPants
Copy link
Collaborator

Replacement PR for #346 since I didn't want to push to the develop branch of @hiddenpants255 repo.

Adds a user agent string configuration option. This user agent string is applied for all http scrape requests.

I've also added an option in the scraper config to print the returned html response in the log. To enable it, add the following to the scraper yml file:

debug:
  printHTML: true

Can be tested with hotguysf**k website. If the agent is not set, then the page is not loaded due to WAF. Setting the agent string to a valid browser results in the correct response. Here is an example config (I have censored the url and title in case of github moderation):

name: Hot Guys F**k
sceneByURL:
  - action: scrapeXPath
    url:
      - hotguysf**k.com
    scraper: sceneScraper
xPathScrapers:
  sceneScraper:
    common:
      $performer: //div[@class='content-meta']/h4[@class='models']/a
    scene:
      Title: //div[@class='videoTitleIntro']/h1
      Details: //div[@class='descriptionIntro']/p
      Date:
        selector: //div[@class='introDatePublished']
        replace:
          - regex: (st|nd|rd|th)
            with:
        parseDate: Jan 02,2006
      Image:
        selector: //div[@class='videoPoster']//img/@src

@WithoutPants WithoutPants added the improvement Something needed tweaking. label Mar 19, 2020
@WithoutPants WithoutPants added this to the Version 0.2.0 milestone Mar 19, 2020
@WithoutPants WithoutPants merged commit abf2b49 into stashapp:develop Mar 20, 2020
Tweeticoats pushed a commit to Tweeticoats/stash that referenced this pull request Feb 1, 2021
* Add debug scrape option.

Co-authored-by: HiddenPants255 <>
@WithoutPants WithoutPants deleted the scraper-user-agent branch February 4, 2021 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Something needed tweaking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants