How Do You Parse And Match The Keyword In Search Engine Url Using Python Re Module?
Example from Google: http://www.google.com.co/url?sa=t&rct=j&q=pedro%20gomez%20proyecto%20en%20la%20ciudad%20de%20valledupar&source=web&cd=10&ved=0CFsQFjAJ&
Try this:
[?&]q=([^&#]*)
Or, better yet:
importurlparsepr= urlparse.urlparse(url)
qs = urlparse.parse_qs(pr.query)['q']
The latter automatically decodes %
-escapes, too.
Post a Comment for "How Do You Parse And Match The Keyword In Search Engine Url Using Python Re Module?"