0

This code works:

    try:
        summary = section.find('p', {'data-testid': 'vuln-summary-0'})
        summary = summary.text
    except AttributeError:
        summary = 'N/A'
    #print (summary)

What I am trying to do is put this in a loop like:

y = 0
while y < 3:

    try:
        summary = section.find('p', {'data-testid': 'vuln-summary-'+y})
        summary = summary.text
    except AttributeError:
        summary = 'N/A'
    y = y +1

I am hoping to get the code to loop through to get vuln-summary-0, vuln-summary-1 and vuln-summary-2.

Thank you.

Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52
Acuity
  • 35
  • 4
  • 2
    What error are you receiving? Also, you may be able to use find_all rather than find. – Captain Caveman May 27 '22 at 17:37
  • Does this answer your question? [How can I concatenate str and int objects?](https://stackoverflow.com/questions/25675943/how-can-i-concatenate-str-and-int-objects) – TDG May 27 '22 at 18:52
  • Please provide enough code so others can better understand or reproduce the problem. – Community May 28 '22 at 04:47

1 Answers1

0

You can change the y to a string and that should give you what you are looking for:

{'data-testid': 'vuln-summary-'+ str(y)}
ArchAngelPwn
  • 2,891
  • 1
  • 4
  • 17