Solved

Help to Modify this code so it works for this website

Posted on 2012-12-20
11
334 Views
Last Modified: 2013-06-17
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
0
Comment
Question by:bsharath
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 11

Author Comment

by:bsharath
ID: 38723147
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?
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 38723312
How about this:
Const strInputFile = "input.txt"
Const strOutputFile = "output.txt"

Const C_URL = "http://mtas.surfcontrol.com/mtas/MTAS.asp"
Const C_TXT = " is in our list and categorized as "

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
While Not objInput.AtEndOfStream
      ' do this now _inside_ the loop because result page does not contain the input form
      objIE.Navigate C_URL
      While objIE.busy = True Or objIE.ReadyState <> 4
            WScript.Sleep 100
      Wend

      strURL = Trim(objInput.ReadLine)
      If strURL <> "" Then
            objIE.Document.form1.URL.Value = strURL
            objIE.Document.form1.submit
            While objIE.busy = True Or objIE.ReadyState <> 4
                  WScript.Sleep 100
            Wend
            ' find category text; note: first integer, then string
            strCategory = InStr(1, objIE.Document.body.innerText, C_TXT, vbTextCompare)
            If strCategory = 0 Then
                  objOutput.WriteLine strURL & ",NOT FOUND"
                  'WScript.Echo strURL & ",NOT FOUND"
            Else
                  strCategory = Mid(objIE.Document.body.innerText, strCategory + Len(C_TXT))
                  strCategory = Left(strCategory, InStr(strCategory, vbCrLf) - 1)
                  'following line is not necessary because property .innerText already strips out HTML
                  'strcategory = Replace(strcategory, "<font color=#CC0000><b>", "")
                  strCategory = Trim(strCategory)
                  objOutput.WriteLine strURL & "," & strCategory
                  'WScript.Echo strURL & "," & strCategory
            End If
      End If
Wend
objInput.Close
objOutput.Close

'Set objHTTP = Nothing
objIE.Quit

Open in new window

0
 
LVL 11

Author Comment

by:bsharath
ID: 38723367
Thanks a lot
Works like a charm

Can you help with this
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/Q_27978528.html

Similar to the first one
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 35

Expert Comment

by:Robert Schutt
ID: 38723563
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.
0
 
LVL 11

Author Comment

by:bsharath
ID: 38724210
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
0
 
LVL 11

Author Comment

by:bsharath
ID: 39237376
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39238091
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?
0
 
LVL 11

Author Comment

by:bsharath
ID: 39238099
>.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
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39244490
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.
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39244506
bit busy at the moment but check this out, second script on this page: http://www.paulsadowski.com/wsh/xmlhttp.htm
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 39252484
I was wrong about parsing the output of that website, will post a solution on your follow-up question shortly.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question