+ Reply to Thread
Results 1 to 4 of 4

Verify if a url gives response without redirection

  1. #1
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Verify if a url gives response without redirection

    Hello friends, I am having a difficult challenge that is not working inspite of several different methods I tried.

    I want to verify the below mentioned 20 urls and find out which one is valid. The urls are in the range A1:A20. Out of these 20, only 2 urls are valid and the remaining are redirected to homepage. The only difference in these urls are that the three letter prefix to the six digits number at the end are different. I have around 500+ urls in column A that I need to verify. I want help in an excel vba code that helps me identify those 2 correct urls and append a text "valid" in the corresponding cell in column B. I have tried a lot of http and xml objects methods that returns headers and responses. however, i was unable to achieve what I desire and appreciate if I can get some help.

    http://www.mywebsite.com/myfolder/on...ABC123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...DEF123456.aspx : valid url
    http://www.mywebsite.com/myfolder/on...GHI123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...JKL123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...MNO123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...PQR123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...STU123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...VWX123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...YZA123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...BCD123456.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...ABC789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...DEF789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...GHI789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...JKL789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...MNO789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...PQR789012.aspx : valid url
    http://www.mywebsite.com/myfolder/on...STU789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...VWX789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...YZA789012.aspx : redirected to http://www.mywebsite.com/Default.aspx
    http://www.mywebsite.com/myfolder/on...BCD789012.aspx : redirected to http://www.mywebsite.com/Default.aspx

    Thank you.

    EDIT
    Actually, I just want to write the 50+ numbers in column A and construct ten different urls with the prefix code ABC, DEF, GHI etc which I will store it in column E. If it is a valid url that does not redirect, the corresponding cell in column b should get a value "Valid" along with the correctly constructed url in column c. If that is possible
    Last edited by sabha; 10-08-2015 at 01:49 PM. Reason: written additional text under EDIT

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Verify if a url gives response without redirection


    Hi,

    which methods did you try ?

    Just compare final URL with source URL …

  3. #3
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Verify if a url gives response without redirection

    I tried the xml method (shown below) but it does not show redirecting url. It just checks if it is valid or invalid and for all my urls, it show valid. Actually, I want to get rid of all the urls that are redirecting to another page and keep only pure urls which do not redirect.

    For example, if I take second url in my original post (given below), it is valid because it does not redirect, the below code also shows it as valid
    http://www.mywebsite.com/myfolder/on...DEF123456.aspx
    but if I take first url in my original post (given below), it is a redirecting url to the above url (second url), ideally its invalid for me because it is redirecting but the code shows valid because of response 200
    http://www.mywebsite.com/myfolder/on...ABC123456.aspx

    Please Login or Register  to view this content.
    All urls given in the question are samples ones and are invalid. It is only for demonstration purpose. I want to process all my urls. if it is a redirecting url, ignore it and if it is a valid url which does not redirect, then append a text "valid" in the corresponding cell in column B. I hope I have explained it better.

    Actually, I just want to keep numbers in column A that will construct 10 different urls automatically for each number and check which one of the 10 is a valid (non-redirecting) url and populate corresponding cell with that url (see the EDIT section in my original post)

  4. #4
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    [PARTIALLY RESOLVED] Re: Verify if a url gives response without redirection

    Ok this is partially resolved. i used the winhttp com object method by adding microsoft xml v6 and microsoft winhttp services version 5.1 in reference. the code is working but now I am finding difficulty in doing it as i mentioned in the edit section of my original post

    Please Login or Register  to view this content.
    If you see the original post, the first ten and next ten urls are same. the difference is only the prefix. Instead of having 20 urls, i just want to have 2 numbers in first two rows (123456 and 789012). I wish to construct 10 urls for first number and check which url is good and not redirecting, once found, populate that url in the corresponding cell in column B. Similarly do it for next number and then for next ........ until all numbers are processed. So if I have 50 numbers, 500 urls should be processed and the good url should be added in column b. (Note: everytime ONLY 1 url will be good out of the ten).

    Thanks
    Last edited by sabha; 10-08-2015 at 11:25 AM. Reason: Edited subject

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Redirection of data from a sheet towards another one in a specific frame
    By Max_F in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-06-2014, 05:17 AM
  2. [SOLVED] Output redirection from BAT or VBS to text file.
    By wherbjr35 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-18-2014, 02:56 PM
  3. verify id?
    By lang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-25-2014, 06:14 PM
  4. Getting URLs for redirection of PDFs
    By bl00py in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2013, 02:25 PM
  5. Windows Vista : Redirection on Internet Explorer
    By Mooseman60 in forum Microsoft Windows Help
    Replies: 3
    Last Post: 09-13-2011, 06:07 AM
  6. verify that a query ran
    By g48dd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-10-2011, 11:22 AM
  7. [SOLVED] Hyperlink Redirection
    By JayH in forum Excel General
    Replies: 1
    Last Post: 06-28-2006, 12:45 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1