Avatar of bsharath
bsharath
Flag for India asked on

Help to Modify this code so it works for this website

help to
Modify this code so it works for this website

http://mtas.surfcontrol.com/mtas/MTAS.asp

retrieve the category to a column

I will have the website names into the txt file

Script scans each site with "mtas.surfcontrol.com" and lists the category


strInputFile = "input.txt"
strOutputFile = "output.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objHTTP = CreateObject("MSXML2.XMLHTTP")

Set objInput = objFSO.OpenTextFile(strInputFile, 1, False)
Set objOutput = objFSO.CreateTextFile(strOutputFile, True)

Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
objIE.Navigate "http://moonsy.com/pagerank_checker/"
While objIE.busy = True Or objIE.ReadyState <> 4
      WScript.Sleep 100
Wend

While Not objInput.AtEndOfStream
      strURL = Trim(objInput.ReadLine)
      If strURL <> "" Then
            objIE.document.form1.domain.value = strURL
            objIE.document.form1.submit.click
            While objIE.busy = True Or objIE.ReadyState <> 4
                  WScript.Sleep 100
            Wend
            strRank = InStr(1, objIE.Document.body.innerText, "your page rank", vbTextCompare)
            If strRank = 0 Then
                  objOutput.WriteLine strURL & ",NOT FOUND"
                  'WScript.Echo strURL & ",NOT FOUND"
            Else
                  strRank = Replace(Trim(Mid(objIE.Document.body.innerText, strRank, 21)), "Your Page Rank:", "")
                  objOutput.WriteLine strURL & "," & strRank
                  'WScript.Echo strURL & "," & strRank
            End If
      End If
Wend
objInput.Close
objOutput.Close

Set objHTTP = Nothing
objIE.Quit
ProgrammingVB Script

Avatar of undefined
Last Comment
Robert Schutt

8/22/2022 - Mon
bsharath

ASKER
Some more info
The current code above places each website name in a site http://moonsy.com/pagerank_checker/ and finds the PR

Now the same code can we change to be placed from txt file each website name into
http://mtas.surfcontrol.com/mtas/MTAS.asp

then find what category the website is from?
ASKER CERTIFIED SOLUTION
Robert Schutt

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
bsharath

ASKER
Thanks a lot
Works like a charm

Can you help with this
https://www.experts-exchange.com/questions/27978528/Find-and-replace-words-in-a-website.html

Similar to the first one
Robert Schutt

I had a quick look but it seems there will be a different screen when you are logged in as administrator (multiple edit buttons?). Maybe you should post some more info like a screendump of how it looks for you and clearly marked which part (or multiple parts) you want to change (and which steps that will entail). I didn't post in that new question because it might put other experts off if you're already receiving help (I have a saved search myself that looks explicitly for questions that have nobody helping yet).

It would probably help attracting other experts if you post a link to earlier solutions (like http:/Q_27976953.html). Also, often it's better to show that you made an effort at solving at least part of it and only then ask for specific help with some adjustments that you can't work out yourself.

HTH, Robert.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
bsharath

ASKER
Thanks Robert

When you login to the post i mentioned with the credentials you can see an Edit button and i will have the same in my admin screen as well but a few others like delete comment etc may be available

I have added the screenshot in that post , please have a look
bsharath

ASKER
Robert Schutt

I'll leave that new question open for now, I'm afraid I don't have the time to try and tackle it today/tonight. At first glance it seems like a horrible task to parse that output, if it's capturable at all. Have you tried looking for code to detect/follow http redirects directly instead of via that website?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
bsharath

ASKER
>.Have you tried looking for code to detect/follow http redirects directly instead of via that website?

No can you please direct me so i can search
Robert Schutt

A quick google shows that it should be possible to use the HTTP request for a HEAD operation instead of the default GET. Then you can determine the new url. If necessary repeat (not sure about that though). I'll have to try it out and if I find something will post on your new question.
Robert Schutt

bit busy at the moment but check this out, second script on this page: http://www.paulsadowski.com/wsh/xmlhttp.htm
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Robert Schutt

I was wrong about parsing the output of that website, will post a solution on your follow-up question shortly.