1

how do i extract certain word in bold below and store the value as input? i managed to get url value as it has referer: text, i would like take value that starting from 1st until it meet '=' sign that is username and continue to catch text start from '&' until '=' which is password?

username=hello&password=test1

AMC
  • 2,466
  • 7
  • 11
  • 31
jane90
  • 27
  • 6
  • Is it always like 5? Is the value always `username` and `password`? – Harshal Parekh Mar 27 '20 at 17:56
  • @HarshalParekh it always in line 5 but the username and password is variables/changeable. that why i want to get text in line 5 from 1st to '=' sign and continue from '&' sign to '=' sign..that store as 2 variables respectively.. – jane90 Mar 27 '20 at 18:17
  • Does this answer your question? [Retrieving parameters from a URL](https://stackoverflow.com/questions/5074803/retrieving-parameters-from-a-url) – AMC Mar 27 '20 at 19:01

1 Answers1

0
for i, line in enumerate(f):  
    # line 5
    if i == 4:
        # get the value from the start of the string to the first "="
        username = line[:line.index('=')]

        # get the value starting from the "&" to the second "="
        password = line[line.index('&') + 1:line.index('=', line.index('=') + 1)]

        print(username, password)

More on index and substring.

Harshal Parekh
  • 4,830
  • 4
  • 13
  • 34