Guest User

Untitled

a guest
Dec 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import re
  2.  
  3. class Client:
  4. # use regex for finding msid and token
  5. def find(self, response, item=None):
  6. if item == 'msid':
  7. text = re.search(r'msid=([\w]*)&msname', response.text).group(1)
  8. elif item == 'token':
  9. text = re.search(r'token=([\w]*)&msid', response.text).group(1)
  10. elif item is None:
  11. raise ValueError('Please provide the items you want to find.')
  12. else:
  13. raise KeyError('The items you are looking for is not available.')
  14. return text
Add Comment
Please, Sign In to add comment