Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: perl Mojo DOM CSS syntax issues

by stevieb (Canon)
on Jan 27, 2024 at 15:51 UTC ( [id://11157302]=note: print w/replies, xml ) Need Help??


in reply to perl Mojo DOM CSS syntax issues

@filex7, Newparse2, $r1, $dom2... those are what I would call "magic numbers"... hard coded information inside code that really shouldn't be there, and that will eventually cause issues. Seems you're currently facing them.

You really want to fetch information from this website through a proper web API.

You can work many nights until 0300 hrs to patch this "large script" until you think it works, until it breaks again, and it will break again.

It's fragile, very poorly written, hard to understand at a glance, and what I'd call easy to break. I also think I'd be safe to say there are no unit tests to compare revisions.

This appears to be an X-Y problem. I would be hesitant to change this script in case it broke something irrelevant to the piece that you want to change. Instead, I'd write a new one to focus on the piece of information you need. At best, ensure you keep revisions of the current script as you change it. Depending on how big it is, with numbered variables like that, any change may break something far away.

Sorry to be the bearer of bad news, but my fix would be to fix it properly, not put a band-aid on it so that the next person has to deal with comments as informative as "#added stuff here 01142012" *

* - If I had a client where I read a comment like that and they didn't permit me to fix things properly, I'd fire them.

Replies are listed 'Best First'.
Re^2: perl Mojo DOM CSS syntax issues
by marto (Cardinal) on Jan 28, 2024 at 09:56 UTC

    "You really want to fetch information from this website through a proper web API."

    Not every website has it's own API, hence people using a parser to achieve what they want, especially one that can cope with css selectors. Not everyone posting here is a professional programmer, nor has the luxury of 'firing' people asking them to do work.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11157302]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-05-21 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found