GithubHelp home page GithubHelp logo

mrmartineau / cloudflare-worker-scraper Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 5.0 38.06 MB

Page Metadata Scraper with Cloudflare workers

TypeScript 83.56% HTML 16.44%
cloudflare-workers scraper

cloudflare-worker-scraper's Introduction

Hi there ๐Ÿ‘‹

My name is Zander

I make things for the web.

Note

When I'm not getting paid to work, I work on one of my many side-projects like Otter, my Code Notes project, Journal or my various Raycast extensions.

Interests and hobbies

  • ๐ŸŒ๏ธโ€โ™‚๏ธ Golf
  • ๐Ÿšตโ€โ™‚๏ธ Mountain biking
  • Making ๐Ÿ• Pizza & ๐Ÿ–๐Ÿ”ฅ BBQ
  • ๐Ÿฟ Movies
  • ๐Ÿฅ Drumming
  • ๐Ÿ’– Salted Caramel

Tip

Feel free to say hello, fork my code or read my blog or checkout my blog/portfolio at zander.wtf

cloudflare-worker-scraper's People

Contributors

mrmartineau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cloudflare-worker-scraper's Issues

Improve link type checker

The link type checker is fairly "unintelligent" at the moment, it looks at the url/path and infers based on that. For example:

  • https://www.youtube.com/watch?v=ctEksNz7tqg would be video
  • something.jpg would be image

All the rules are in the types.ts file, but I'm sure they can be improved.

Does anyone have a better solution?

JSON LD on Youtube videos needs improving

The 1st two JSON LD selectors have been specifically added to get more accurate data for YouTube videos, but it seems HTMLRewriter is not able to parse them. I think this might be due to the JSON LD script being within a web component..

The selectors are:

[
  {
    selector:
      '#content #microformat script[type="application/ld+json"]',
  },
  {
    selector:
      'ytd-player-microformat-renderer script[type="application/ld+json"]',
  },
  {
    selector: 'script[type="application/ld+json"]',
  },
]

Are there better set of selectors that can be used to get this information?

[enhancement] Add option to delay & add proxy rotation

This is the first time in a long time I saw code being structred and written so well, that it even makes sense just by looking at it. Simply awesome how you managed to do that & its helping me a lot to plan & structure my own stuff.

On a side note: you might like to check the awesomeness from https://github.com/AutomaApp/automa & how they automate stuff in the browser. Not so much for coding but for possible workaorunds & fallback scenarios.

[Suggestion to take your code provided even further]
The following is a braindump of features that would make your scraper even more awesome. Consider it being wishful thinking and not a complaint about missing stuff.

  1. Allow for finding sitemap.xml and convert to json

  2. Allow using json path to filter results from previous step to e.g. only follow ./products/*

  3. Scrape the metadata from previous step ('products' in this example)

    3.1 Additional feature enhancement to this: allow following a specific URL from within that product page to scrape additional data (e.g. if the parent prodcut page holds a 'manufactorer' tag or class, follow that link to provide additional meta data by following the related manufactorer link provided to get e.g. the SKU or whatever from that page too in a single attempt)

  4. Add an option to set a threshold to randomly delay requests
    Context: Reduce being spotted as robot + Avoid IP adress ban for too many requests from same IP adress origin within a timeframe

  5. Alternatively to previous step or even as addition: SloMo mode (e.g. set a timeframe in which the crawler should operate (e.g. parse list over a time period of 12 hours)

  6. Allow IP adress rotation (no idea how this can be achieved) or to create/specify local proxy

  7. Allow to set / update / delete cookie prior parsing (e.g. to log in or fake fresh user or ....

Knowing ou likely got other stuff to do, I still hope you might consider the one or the other or at least think about way to allow others creating "modules" that plug-in to what you shared already.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.