Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-01-2015, 01:32 PM
edneco edneco is offline VBA code to login a web site and extract data to excel Windows 7 32bit VBA code to login a web site and extract data to excel Office 2007
Novice
VBA code to login a web site and extract data to excel
 
Join Date: Jun 2014
Posts: 12
edneco is on a distinguished road
Default VBA code to login a web site and extract data to excel

Hello everyone...



My knowledge of VBA code is very very limited. The only code I made is from recording some macros.... So you see what point I'am.....

I can get some data from websites trough Excel-> Data -> From Web and then pick the yellow boxes to import tables (when the sites allow it)..... In my specific case I need to import some data from this site: www.betbrain.com

I donīt know if you know this site. This site is about sports and betting. I want to import the odds from specific football leagues with some specific odds (Bet365)..... In my website preferences, when I login, the Bet365 odds are show in every match. If I donīt login, the odds that appear is the best odds we can bet.

So, I need to login with my username and password to get the odds I want and copy them to excel.

I donīt know either if is its possible to do what I want with VBA code. I hope it can......

In this link we have the Premier League (UK) games for the 1st round.

http://www.betbrain.com/football/eng...remier-league/


Thank you in advance for any help you can give me on this.......


Cheers, Eduardo


PS -> In the future Iīll need some help to "convert" this to a userform (like an application)......
Reply With Quote
  #2  
Old 07-02-2015, 11:07 AM
charlesdh charlesdh is offline VBA code to login a web site and extract data to excel Windows 7 32bit VBA code to login a web site and extract data to excel Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

HI,

I looked at your request. But, from what I can see is that there are several "Bet365" how would you determine which one to download.And to the data is always changing.
So, I'm inclined to say this would be a very complex program to create. I for one would not be able to help in this matter.
A word of advice. You have this same question at other sites. It would be nice if you let us know. I for one have a problem with cross post and not knowing.
Good luck!
Reply With Quote
  #3  
Old 07-02-2015, 11:26 AM
edneco edneco is offline VBA code to login a web site and extract data to excel Windows 7 32bit VBA code to login a web site and extract data to excel Office 2007
Novice
VBA code to login a web site and extract data to excel
 
Join Date: Jun 2014
Posts: 12
edneco is on a distinguished road
Default

Hello charlesdh and thank you for your attention....

If you go to the link I posted with the premier league matches, you see all of the of the first round. You also see the odds for each outcome (home win, draw and away win)....

But unless you login you see the best odds we can bet.

Example
Arsenal 1,50 - pinnacle
Draw 5,0 - betfair
Hull 8,5 - bet365

But if you login into the site you can choose then wich bookies you want (in my case I need the bet365 odds)....

Yes, the odds may vary every day. I just want that when I hit a button, enter the site, login, go to a specific league and put the matches and the odds into a sheet....

I don't know if this is a tricky one or not.... I can't do it by myself....


Yes, I put this post in another forum.... Don't know if I can't do this... If not I'm sorry....
Reply With Quote
  #4  
Old 07-07-2015, 11:35 AM
edneco edneco is offline VBA code to login a web site and extract data to excel Windows 7 32bit VBA code to login a web site and extract data to excel Office 2007
Novice
VBA code to login a web site and extract data to excel
 
Join Date: Jun 2014
Posts: 12
edneco is on a distinguished road
Default

Hello again.....

Iīve found this code in the internet and modify it to suit me, but as a problem.....

I run the code and the IE open in the site I want by then donīt login..... Gives me an error.....

It says:

type Status report
message HTTP method POST is not supported by this URL
description The specified HTTP method is not allowed for the requested resource.


How can I fix this??? The code is this:


Code:
Dim HTMLDoc As HTMLDocument
Dim oBrowser As InternetExplorer
Sub Login_2_Website()

Dim oHTML_Element As IHTMLElement
Dim sURL As String

On Error GoTo Err_Clear
sURL = "https://www.betbrain.com/"
Set oBrowser = New InternetExplorer
oBrowser.Silent = True
oBrowser.timeout = 60
oBrowser.navigate sURL
oBrowser.Visible = True

Do
' Wait till the Browser is loaded
Loop Until oBrowser.readyState = READYSTATE_COMPLETE

Set HTMLDoc = oBrowser.document

HTMLDoc.all.UserName.Value = "******"
HTMLDoc.all.Password.Value = "********"

For Each oHTML_Element In HTMLDoc.getElementsByTagName("input")
If oHTML_Element.Type = "submit" Then oHTML_Element.Click: Exit For
Next

' oBrowser.Refresh ' Refresh If Needed
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub

If anyone can help me on this......
Reply With Quote
  #5  
Old 07-07-2015, 02:05 PM
charlesdh charlesdh is offline VBA code to login a web site and extract data to excel Windows 7 32bit VBA code to login a web site and extract data to excel Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Hi,

I found this bit of code see if you can use it. I'm not web savey. This is only to see if it helps you.
There is a lot of sample code out there...

Code:
Option Explicit 
 
Sub IE_login() 
    Dim ie As InternetExplorer 
    Dim C 
    Dim ULogin As Boolean, ieForm 
    Dim MyPass As String, MyLogin As String 
     
redo: 
    MyLogin = Application.InputBox("Please enter your VBAX login", "VBAX username", Default:="login", Type:=2) 
    MyPass = Application.InputBox("Please enter your VBAX password", "VBAX Password", Default:="Password", Type:=2) 
     
    If MyLogin = "" Or MyPass = "" Then GoTo redo 
     
    Set ie = New InternetExplorer 
    ie.Visible = True 
    ie.Navigate "http://www.vbaexpress.com" 
     
     'Loop until ie page is fully loaded
    Do Until ie.ReadyState = READYSTATE_COMPLETE 
    Loop 
     
     'Look for password Form by finding test "Password"
    For Each ieForm In ie.Document.forms 
        If InStr(ieForm.innertext, "Password") <> 0 Then 
            ULogin = True 
             'enter details
            ieForm(0).Value = MyLogin 
            ieForm(2).Value = MyPass 
             'login
            ieForm.submit 
            Exit For 
        Else 
        End If 
    Next 
    If ULogin = False Then MsgBox "User is aleady logged in" 
    Set ie = Nothing 
End Sub
Code:
Sub SetRefs() 
    Dim ObRef 
    On Error Resume Next 
     ' Adds Internet Controls Ref
    ThisWorkbook.VBProject.References.AddFromGuid "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 1, 1 
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Require assistance in writing code to login to webmail account. saurabhlotankar Excel Programming 4 05-21-2015 10:47 AM
VBA code to login a web site and extract data to excel Extract Excel Data from Chart in Word cillianmccolgan Word 1 08-15-2014 01:42 AM
VBA code to login a web site and extract data to excel How to extract data from Excel database to create word report for each patient (row) nightale Word 3 07-06-2014 04:17 PM
Macro to login to horseracebase.com web site and download today cards file Catalin.B Excel Programming 3 10-20-2013 10:02 AM
Extract Numbers from Zip Code Karen615 Excel 3 09-21-2011 06:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:34 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft