Results 1 to 8 of 8

Thread: 301 Move Permanent

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Post 301 Move Permanent

    Hi, I have been succesfull accessing a site Http://ich.... , now the site start using ssl Https:// and I get a 301 Moved Permanent, and show Location https://ich....., can someone please help me fix the code, thanks
    in advance. Tony

    ------------------------------------------------------------
    Function URLstripHttP(ByVal tUrl$) As String
    tUrl$ = Trim(tUrl$)
    If Left$(LCase(tUrl$), 7) = "http://" Then
    URLstripHttP$ = Right$(tUrl$, Len(tUrl$) - 7)
    Else: URLstripHttP$ = tUrl$
    End If
    End Function
    ----------------------------------------------------------------------
    Function URLHost(ByVal tUrl$) As String
    tUrl$ = Trim(tUrl$)
    tUrl$ = URLstripHttP(tUrl$)
    pos = InStr(tUrl$, "/")
    If pos = 0 Then
    URLHost$ = tUrl$
    Else
    URLHost$ = Left(tUrl$, pos - 1)
    End If
    End Function
    ------------------------------------------------------------------------
    Function URLDocument(ByVal tUrl$) As String
    tUrl$ = Trim(tUrl$)
    tUrl$ = URLstripHttP(tUrl$)
    For A = 1 To Len(tUrl$)
    If Mid$(tUrl$, A, 1) = "/" Then
    URLDocument = Right$(tUrl$, Len(tUrl$) - A)
    Exit Function
    End If
    Next
    URLDocument = "": Exit Function 'Not Found
    End Function
    ------------------------------------------------------------------
    Function UrlMsg$(ByVal tUrl$) ' pretend to be a browser
    tDocument$ = URLDocument(tUrl$)
    Dim tHost$

    Msg$ = ""
    Msg$ = Msg$ + "GET /" & tDocument$ & " HTTP/1.1" & vbCrLf
    Msg$ = Msg$ & "Host:" & URLHost(tUrl$) & vbCrLf 'NEW LINE ADDED
    Msg$ = Msg$ + "Accept: */*" & vbCrLf
    Msg$ = Msg$ + "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" & vbCrLf
    Msg$ = Msg$ + "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0" & vbCrLf
    Msg$ = Msg$ + "Accept-Language: en-us,en;q=0.5" & vbCrLf
    Msg$ = Msg$ + "Connection: Close" & vbCrLf


    Msg$ = Msg$ & vbCrLf
    UrlMsg$ = Msg$
    End Function
    ---------------------------------------------------------------------

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,858

    Re: 301 Move Permanent

    What about changing these 2 lines:
    Code:
    If Left$(LCase(tUrl$), 7) = "http://" Then
    URLstripHttP$ = Right$(tUrl$, Len(tUrl$) - 7)

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: 301 Move Permanent

    Thank you Arnoutdv for your reply, I try change the http to https and the seven to 8, but still don't fix the issue. Still use http:// instead https://.

  4. #4
    Hyperactive Member
    Join Date
    Mar 2017
    Posts
    498

    Re: 301 Move Permanent

    What is the value of tUrl$ and how do you run your posted code

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: 301 Move Permanent

    Hi, Thank you for relying, the code is running from a program to download quotes from Yahoo, but yahoo changed to https last week and the program stop working. site is https://ichart.yahoo.com .
    Tks

  6. #6
    Hyperactive Member
    Join Date
    Mar 2017
    Posts
    498

    Re: 301 Move Permanent

    That didn't answer my question

    Again:
    What is the value of tUrl$ and how do you run the code. How are the functions called

  7. #7
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    3,858

    Re: 301 Move Permanent

    Quote Originally Posted by Tony. View Post
    Thank you Arnoutdv for your reply, I try change the http to https and the seven to 8, but still don't fix the issue. Still use http:// instead https://.
    You really have to show more of your code.
    How are you calling the routines, what's the input

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Feb 2015
    Location
    USA, New Jersey
    Posts
    23

    Re: 301 Move Permanent

    Hi, I don't know exactly what part of code to show. I'm a computer tech , and I'm try to fix and learn at the same time. I will update as soon I find out what code to show.
    Last edited by Tony.; May 6th, 2017 at 04:19 PM. Reason: Change comment

Posting Permissions

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



Click Here to Expand Forum to Full Width