Python Combing Two Commands
I have been digging deeper into Python and want to make my code as efficient as possible. The less line of code the better so I have been experimenting and wanted to ask the Python gurus if this is possible. So:
Code:
... https://support.microsoft.com/kb/3020393 So is it possible to combine kbfileinfo,group with re,compile: Code:
kbfileurl.group().encode('ascii')re.compile(r'\bhttps://support.microsoft.com/kb/d+\b') https://support.microsoft.com/kb/3020393 ?? |
After playing around with it, I did a small modification and came up with but not exactly a one-liner:
Code:
In [201]: kbfileurl = re.search('<p>For more information about this update.*</p>', tbull.text.encode('utf8')).group() |
You should not write your own regex to parse HTML in the real world, but nothing wrong with trying to do it for learning.
Anyway, you should be doing this with one regex search. If this works, it works: Code:
re.search(r'\bhttps://support.microsoft.com/kb/d+\b', CONTENTS_OF_ENTIRE_FILE) |
All times are GMT -5. The time now is 11:29 PM. |