egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Parsing from webcontent

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Elfriede
Halfop


Joined: 07 Aug 2007
Posts: 67

PostPosted: Wed Jan 26, 2011 10:14 am    Post subject: Parsing from webcontent Reply with quote

Hi @ all Smile

I'd like to parse ->

Code:
<a href="/genre/Action">Action</a>&nbsp;<span>|</span> <a href="/genre/Adventure">Adventure</a>&nbsp;<span>|</span> <a href="/genre/Comedy">Comedy</a>


the genres, like Action/Adventure/Comedy. What i have

Code:

   foreach line [split $content \n] {

if {[regexp -nocase {<a\shref="\/genre\/(.*)">(.*)<\/a>} $line match genre1 genre2 genre3]} {


and i knwo, that is bad. Next problem: Im not knowing at the beginning how many genres ill have to parse. it can be just one or up to 4 or somethg like that.

Thank you !
Back to top
View user's profile Send private message
Trixar_za
Op


Joined: 18 Nov 2009
Posts: 143
Location: South Africa

PostPosted: Wed Jan 26, 2011 12:15 pm    Post subject: Reply with quote

Could you post the link to the website? Might be easier to see how it handles different kinds of input and how it changes the code.

foreach is a good start btw, but why don't you add each match to the end of a single variable like set real_var "$real_var|$match" - this way you don't need to make the regex match do all the work and you get a near unlimited amount of genres you could add so long as they match the regex. They'll all end up looking like Adventure|Action|Fantasy with the above example.
_________________
http://www.trixarian.net/Projects
Back to top
View user's profile Send private message Visit poster's website
Elfriede
Halfop


Joined: 07 Aug 2007
Posts: 67

PostPosted: Wed Jan 26, 2011 12:39 pm    Post subject: Reply with quote

http://www.imdb.com/title/tt0942385/

Quote:
set real_var "$real_var|$match"


Sounds good Smile Im excited to see how that proc part will look like
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber