L
lrlebron
I am trying to parse strings like this
<a href='showmono.asp?cpnum=1022&monotype=comb' target='main'>
I need to get the cpnum value (555)
I am using the following function
def get_drugId(link)
arrParts = link.html.split('?')
cpnum = arrParts[1].split('&')
cpnumparts= cpnum[0].split("=")
drugId = cpnumparts[1]
end
but I imagine there is a simpler way to do this. Also, I would like
something more flexible that would return all the query parameters (if
there are more than one) in an array or a hash.
Any ideas?
thanks,
Luis
<a href='showmono.asp?cpnum=1022&monotype=comb' target='main'>
I need to get the cpnum value (555)
I am using the following function
def get_drugId(link)
arrParts = link.html.split('?')
cpnum = arrParts[1].split('&')
cpnumparts= cpnum[0].split("=")
drugId = cpnumparts[1]
end
but I imagine there is a simpler way to do this. Also, I would like
something more flexible that would return all the query parameters (if
there are more than one) in an array or a hash.
Any ideas?
thanks,
Luis