r/learnpython • u/cheriieriot • 2d 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
17
Upvotes
10
u/sayitagain09 1d ago •
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.
3
u/Sabinesora 1d ago •
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?
2
u/EnvironmentalDot9131 1d ago
The same fields are good
1
u/white-9igga 2d 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 1d 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 1d 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 1d 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 1d 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.
1
u/lazy_bunny43 1d ago
Job board scraper here, dates are the worst part, every sites write them differently.