-1

I have an html file in which I want to replace the value of a variable inside of it, like that for example

name = 'x' value= '50'

I want to replace the value from any number to a specific number like 13,The problem is I don't know what is the current value so I need a way that python replace the current value no matter what value it is, but for sure I know it is an integer.

user5324426
  • 693
  • 1
  • 5
  • 12
  • 1
    you need to utilize an HTML parser (I'd recommend `BeautifulSoup`). Then just locate the node in the document via xpath, and edit the value of the attribute you want. – yedpodtrzitko Mar 21 '16 at 09:52
  • I am sure there is a way to use the replace function that will be easier than using an HTML parser – user5324426 Mar 21 '16 at 09:55

1 Answers1

-1

Make use of regular expressions. Read your html file and find all the variable occurrences in the file and replace it with the your interested value.

NMN
  • 372
  • 3
  • 16