Jump to content

RegEx Help - Parsing HTML


Ned
 Share

Recommended Posts

Why will this not work? I have spent a few hours on this one little problem. I have tried everything I can think of to make it work, but never wants too. I have tested the pattern in a few other scripts and it works fine. the @ERROR says it is a bad string - but how can String($HTML) be bad? Is it to much text for it to string?

$IE = _IECreate("C:\Users\Ned\Dropbox\Public\Findings.html", "", 0)
$HTML = _IEBodyReadHTML($IE)
_IEQuit($IE)
$HTML = String($HTML)
$array = StringRegExp($HTML, '(?<=\QNew: <a href="/items/view/\E)(.*?)(?=\Q">\E)', 3) ;gets new item numbers
_ArrayDisplay($array)
Edited by Ned
Link to comment
Share on other sites

I dont see any error checking. How do you know its coming from String()? Have you tried printing $HTML to the console to verify that _IEBodyReadHTML() worked?

Link to comment
Share on other sites

Wait...If you manually add the string $html to your script it works? That is weird. I have a few ideas that might work, but nothing to figure out whats actually going wrong. Maybe try putting on the clipboard and then reading back?

Clipput($html)
$html = clipget()

If that doesnt work maybe :graduated:

Clipput($html)
$html = clipget()
_filecreate(@scriptdir & '\Temphtml.txt')
filewrite(@scriptdir & '\Temphtml.txt', $html)
$html = fileread(@scriptdir & '\Temphtml.txt')
filedelete(@scriptdir & '\Temphtml.txt')
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...