Sign in to follow this  
Followers 0
bigevilfish

Replace HTML String

3 posts in this topic

Hello All

 

First time posting, long time lurking and learning.

I need to replace some html in multiple files one after the other with some information from an excel spreadsheet

 

for example the HTML file contains this string

Reference:</td><td style="padding: 0px 10px 0px 10px;margin: 2px;font-size: 8pt;">

 

i want to add a value to the end like so

 

Reference:</td><td style="padding: 0px 10px 0px 10px;margin: 2px;font-size: 8pt;">$VISION_ID

but as the string contains " I'm not sure how to work around it

I know the answer will be simple but i just can't figure this one out

 

this is how far i got until i had trouble with the "

 

Sleep (1000)
Local $FromTo = $oWorkbook2.Worksheets(1).Range("B1").Value       
Sleep (1000)
Local $sFind = "Reference:</td><td style="padding: 0px 10px 0px 10px;margin: 2px;font-size: 8pt;">"
Local $sReplace = $FromTo
Local $sFilename = "C:\extract\Daily_import.html"
Local $iRetval = _ReplaceStringInFile($sFilename, $sFind, $sReplace)
Sleep (1000)

 

 

 

Thanks in advance

 

 

Share this post


Link to post
Share on other sites



Try surrounding your string with single quotes

'Reference:</td><td style="padding: 0px 10px 0px 10px;margin: 2px;font-size: 8pt;">'

That way everything within the single quotes is treated as the string.


Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Share this post


Link to post
Share on other sites

omg!! so simple!

 

:> thank you (i was working my way through """ /"" /"/ and so on)

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      Before all, I want to say that I'm doing this script to see how _IE* functions work, and see if my studs can hack a quiz I'm working on.
      I want to clarify that I'm not automating any game, bypassing any CAPTCHAs, or anything that could damage anyone.
      I was trying to autofill a form, based on which question is displayed.
      The question is always stored in here:
      <header> <h1><span class="questionid">1. </span>Here goes the question</h1> </header> And answers are stored in here:
      <ul class="answers"> <li><label><span><input id="answer_0" name="answer[]" type="radio" value="0">Answer 1</span></label></li> <li><label><span><input id="answer_1" name="answer[]" type="radio" value="1">Answer 2</span></label></li> <li><label><span><input id="answer_2" name="answer[]" type="radio" value="2">Anwser 3</span></label></li> <li><label><span><input id="answer_3" name="answer[]" type="radio" value="3">Answer 4</span></label></li> </ul></fieldset></form></div> And, there are 15 questions like this.
      How can automatically fill my form?
      Thanks in advance
      Francesco
    • houser747
      By houser747
      I have previously used _IEFormElementGetObjByName and _IEFormElementSetValue to enter text into a search box on a form and then submit the form.
      I am now trying to enter text into a search box which is not part of a form. 
      Here is the HTML from the website that i'm trying to enter the data on and then submit the search.
      <div class="row">
          <div class="form-group col-xs-12">
              <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_lblSearchText" for="input-search">Registreringsbeteckning</span>
              <div class="input-group col-xs-12">
                  <span id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_preSearchText" class="input-group-addon">SE -</span>
                  <input name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$txtSearchText" type="text" value="DTH" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_txtSearchText" class="form-control" />
              </div>
          </div>
      </div>
      <div class="row">
          <div class="form-group col-xs-12">
              <label class="sr-only" for="">Sök</label>
              <input type="submit" name="ctl00$FullWidthWithSubmenuContent$FullWidthContent$MainContent$AircraftRegistry$btnSearch" value="Sök" id="FullWidthWithSubmenuContent_FullWidthContent_MainContent_AircraftRegistry_btnSearch" class="btn btn-primary ladda-button" data-style="expand-right" />
          </div>
      </div>
      Many thanks in advance
      cheers
      Roger
    • SkysLastChance
      By SkysLastChance
      #include <IE.au3> #include <MsgBoxConstants.au3> Local $oIE = _IECreate("website") Local $oForms = _IEFormGetCollection($oIE) For $oForm In $oForms MsgBox($MB_SYSTEMMODAL, "Form Info", $oForm.name) _IEImgClick($oForm.name, "Reserved.ReportViewerWebControl.axd?OpType=Resource&amp;Version=12.0.5522.0&amp;Name=Microsoft.ReportingServices.Rendering.HtmlRenderer.RendererResources.TogglePlus.gif", "src") Next I am having trouble clicking an image. Here is what I have tried. 

    • Jefrey
      By Jefrey
      I've made this HTTP lib to simplify HTTP requests, mainly when dealing about POST data or file uploads.
      Three functions are available:
      string _HTTP_Get ( string $sURL ) string _HTTP_Post ( string $sURL , string $sPostData ) string _HTTP_Upload ( string $sURL , string $sFilePath , string $sFileField , string $sPostData = '' , string $sFilename = Default) Additionaly, two helper functions are also available:
      URLEncode($sStr) URLDecode($sStr) Full documentation: https://github.com/jesobreira/HTTP.au3/blob/master/README.md
      Fork me on Github: https://github.com/jesobreira/HTTP.au3
      Download lib + docs: https://github.com/jesobreira/HTTP.au3/archive/master.zip
    • mjolnirmarkiv
      By mjolnirmarkiv
      Hi!
      Does anyone have any idea why Test() returns 0, while Test2() returns 1?
      #include <IE.au3> MsgBox(0, "", Test() & " " & Test2()) Func Test() Local $oHTML = ObjCreate("HTMLFILE") $oHTML.body.innerHTML = FileRead("Test.html") Return IsObj($oHTML.getElementsByClassName("example")) EndFunc Func Test2() Local $oIE = _IEAttach("", "instance", 1) Return IsObj($oIE.document.getElementsByClassName("example")) EndFunc Sample Test.html I open in IE before testing:
      <!DOCTYPE html> <html> <body> <p class="example"></p> <div class="example"></div> </body> </html> I'm receiving html text in a response to http request, I need to parse it fast and easy, getElementsByClassName would have been ideal. I'm using 3.3.12.0 version.