r/learnpython • • 15h ago

pulling the same fields off a bunch of venue sites and now every site has its own parser, is there a saner way

same stuff on every venue site. name, date, price, ticket link. but each one hides it somewhere else, a table on one, cards on another, and a couple only fill in after the js runs so those go through playwright

so now theres a parser per site, and when a venue redesigns i find out because my list goes quiet

do people just live with one parser per layout or is there a way to describe the fields once​

21 Upvotes

18 comments sorted by

5

u/sayitagain09 13h ago • Bravo

The js venues dont need their own route. stagehand runs its core inside the browser, and the browser has already run the pages js, so those venues go through the same code as the plain ones.

2

u/Baner-Fournadet 8h ago

tbh just not having to maintain two separate scraping pipelines makes the browser overhead worth it.

3

u/Sabinesora 13h ago • Bravo

Judge any replacement for the parsers on the week a venue redesigns, because that week is the one that costs you. my ticket scrapers only find out by coming back empty too. How does stagehand handle a step it already recorded once the venue rearranges the page?

1

u/Proud_Bath_1671 7h ago

whatever you end up running, an alert when a parser comes back with zero rows is cheap. Mine goes to my phone and has caught every redesign so far (a couple this year)

2

u/EnvironmentalDot9131 12h ago

The same fields are good

1

u/white-9igga 14h ago

the other half of your question is the "i find out because my list goes quiet" part, thats worth fixing no matter which extraction route you pick. for each site keep a tiny check after every run, like how many events it returned compared to last time and what share of them have all four fields filled, and if a site drops to zero or half or starts returning empty prices, flag it right away. then a redesign shows up as an alert the same day instead of you noticing weeks later.

also save the raw html of each run for a bit, so when a parser breaks you can see what changed and test the fix against the saved page instead of waiting for the site again

1

u/SilentNova63 13h ago

Same thing at work with supplier product pages. every one has dimensions, weight and part number, and every one lays them out its own way. a new supplier just sits in the backlog until someone has a free day to write its parser, and until then we get nothing from them at all

1

u/miss_strawberryxx 7h ago

Check the page source for a schema.org Event in a script tag first, plenty of venue sites ship one. Where there isn't one, anchor on the label text instead of the position. Find the element that says "Date" or "Tickets" and read its neighbour.

1

u/AdhesivenessFew8441 3h ago

Before writing more parsers, check if the venues already publish the data for Google. A lot of ticketing and venue sites include schema.org Event data in a script tag of type application/ld+json so they show up in Google event results, and it has exactly your fields: name, startDate, location, offers.price and offers.url. The extruct library pulls that out of any page in one call, so for those sites you have one parser for all of them, and it rarely breaks on a redesign because their SEO depends on it. Keep your custom parsers only for the venues that do not have it. And like others said, alert on zero results per venue, plus check that dates still parse, since a redesign sometimes returns rows with empty fields instead of no rows.

1

u/LegalDebate5423 3h ago

You may still need a small adapter per site, but give every adapter the same output contract, e.g. a list of records with name, date, price, and ticket_url. Then run the same validation after each parser and alert when a venue suddenly returns zero events or missing fields. That keeps site-specific selectors isolated without letting a redesign fail silently.

0

u/ShayanWrites 15h ago

you can get most of the way there with one generic extractor plus a small selectors config per site, so a redesign means editing a line of config instead of a whole parser. for the js ones it's worth opening the network tab first, a lot of those sites load the events from a json endpoint or have JSON-LD Event data in the page source, which is way sturdier than scraping the rendered html. and add a check that yells when a field comes back empty, that way you hear about a redesign right away instead of when the list goes quiet.