473,499 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

looping thru URL

2 New Member
I have a list of urls that i would like to keep looping thru. Every time the url is opened curtain data is scraped out then posted in correct row and columns. so far I can get my marco to loop thur the url but the data that i want is not posting coreectly. please let me know how to fix. I have attached a copy of the speadsheet for you to review.
Attached Files
File Type: zip TEST RSS.zip (34.4 KB, 99 views)
Sep 14 '12 #1
5 2120
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
Hi lasilva and welcome to Bytes.

Please do not take offense, but since this is your first post and I as such, do not know you, I have no intention of downloading attachments from you, and I believe that many of our experts feels the same way.

If you would care to poste the code here, indicating where you believe the problem might be, I would be happy to take a look at it for you.
Sep 14 '12 #2
lasilva
2 New Member
ok Here is the code I am using now

Expand|Select|Wrap|Line Numbers
  1. Sub URL()
  2. '§ Keyboard Shortcut: Ctrl+Shift+L
  3. Dim ARRURL() As String '§ for splitting the URL
  4. Dim QT As QueryTable '§ QueryTables in sheet
  5. Dim URLDATArow As Integer
  6. Dim URLDATAitem As String
  7. Dim URLDATAdata As String
  8. Dim URLDATAitemline As Integer
  9. '§ go to first cell
  10.     Range("O2").Activate
  11. '§ loop through sheet
  12.     Do While ActiveCell.Value <> ""
  13. '§ split URL on "/" in array
  14.         ARRURL = Split(ActiveCell.Value, "/")
  15.         With ActiveSheet.QueryTables
  16.             With .Add(Connection:="URL;" & ActiveCell.Value, _
  17.                         Destination:=Range("URLdata"))
  18.                 '§ search .Name !! URL can or can NOT end on "/"
  19. If InStrRev(ActiveCell.Value, "/") = Len(ActiveCell.Value) Then
  20.                     .Name = ARRURL(UBound(ARRURL) - 1)
  21.                 Else
  22. .Name = ARRURL(UBound(ARRURL))
  23.                 End If
  24. .FieldNames = True
  25.         .RowNumbers = False
  26.         .FillAdjacentFormulas = False
  27.         .PreserveFormatting = True
  28.         .RefreshOnFileOpen = False
  29.         .BackgroundQuery = True
  30.         .RefreshStyle = xlInsertDeleteCells
  31.         .SavePassword = False
  32.         .SaveData = True
  33.         .AdjustColumnWidth = True
  34.         .RefreshPeriod = 0
  35.         .WebSelectionType = xlEntirePage
  36.         .WebFormatting = xlWebFormattingNone
  37.         .WebPreFormattedTextToColumns = True
  38.         .WebConsecutiveDelimitersAsOne = True
  39.         .WebSingleBlockTextImport = False
  40.         .WebDisableDateRecognition = False
  41.         .WebDisableRedirections = False
  42.         .Refresh BackgroundQuery:=False
  43. End With
  44.         End With
  45.         '§ clear QueryTables
  46.         For Each QT In ActiveSheet.QueryTables
  47.             QT.Delete
  48.         Next
  49. '§ set data in cells and go 1 cell down
  50.         With ActiveCell
  51.             '§ move data
  52.             For URLDATArow = 1 To Range("URLdata").Rows.Count
  53.                 URLDATAdata = Range("URLdata").Cells(URLDATArow, 2).Value
  54.                 If URLDATAdata <> "" Then
  55.                     If Range("URLdata").Cells(URLDATArow, 1).Value <> "" Then
  56.                         URLDATAitem = Range("URLdata").Cells(URLDATArow, 1).Value
  57.                         URLDATAitemline = 1
  58. Else
  59.                         URLDATAitemline = URLDATAitemline + 1
  60.                     End If
  61.                     Select Case URLDATAitem
  62. Case "displayEmail =:"
  63.                         Select Case URLDATAitemline
  64.                         Case 1
  65.                             .Offset(0, 9).Value = URLDATAdata
  66. Case 2
  67.                             .Offset(0, 10).Value = URLDATAdata
  68.                         End Select
  69.                     Case "<h2>:"
  70.                         .Offset(0, 11).Value = URLDATAdata
  71. End Select
  72.                 End If
  73.             Next
  74.             '§ go 1 cell down
  75.             .Offset(1, 0).Activate
  76.         End With
  77.         ActiveSheet.Range("URLdata").Clear
  78.     Loop
  79. End Sub


I believe it has to do with destination part of the code I dont think im doing this right
Sep 14 '12 #3
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
I have looked a bit at your code, and not springs to mind as "obviously wrong", but I haven't used any code similar to yours really. I am guessing its a logic error, and I would suggest you try stepping through the code.

For more information on debugging in vba try looking at:
Debugging in VBA
Sep 15 '12 #4
zmbd
5,501 Recognized Expert Moderator Expert
When you say the data isn't posting correctly, what do you mean... please give us an example.
Are you getting any errors? If so, what number and description?

-z
Sep 15 '12 #5
Guido Geurs
767 Recognized Expert Contributor
The code seems to be OK but in the URL pages there is no "displayEmail =:" on which you want to capt the data from.

PS: be carefully with names: there is also a macro with the same name as the named-range: "URLdata"

I have attached a code in which you can see the data of the URLs for 5 seconds.
If you want a longer time, change the 5 to a higher value.
Attached Files
File Type: zip TEST RSS_test1.zip (33.0 KB, 93 views)
Sep 18 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1762
by: sparks | last post by:
I was going to loop thru the tables and change some properties. 10 <<<<<< prp.value --prp.name = Type False <<<<prp.value --prp.name = allow zero length 10 <<<<<< prp.value --prp.name = Type...
1
1963
by: u473 | last post by:
I am still a beginner with VBA and I need the VBA Code for the following problem. I have a list of activities with their Scheduled Start date, Duration, and Working hours in Table1. I need to...
2
1211
by: Krish | last post by:
I have Type System.Object and the value is {System.Array} I see ....... in the watch window. How do I traverse such a data structure. thanks for any help.
5
1731
by: Craig G | last post by:
how do i go about this thru serverside code (VB.NET)? any links to any articles anywhere? basically i just want something simple that will loop thru all txt & cbo server side controls, and then...
1
1389
by: Jim in Arizona | last post by:
Using VB .. Is there a way to loop through all drop down lists on a web form checking for a specific value (ddlDropDown.SelectedValue) and then, based on that value, cause a specific label to go...
2
16036
by: pob | last post by:
Whats the difference between using a control or a listbox when looping thru a listbox. In example 1 it dims a listbox and an example 2 it dims a control. Please explain. Thanks in advance ...
1
16622
by: pds79 | last post by:
Hi everyone, I'm a newbie to the forum. I have an issue and was hoping to get some assistance/ideas: Im trying to read a XML file into two record sets. I can acheive looping through the...
1
1534
by: tshad | last post by:
I was trying to do this in Javascript but found I can't do spans (which is what Labels turn into). I can do a loop thru a control list something like: Public Sub LoopingControls(ByVal oControl...
6
2716
by: mahowe | last post by:
Hi, I have had this problem for a while and have not been able solve it. What im looking at doing is looping thru my patient table and trying to organise the patients in to there admission...
4
5103
by: sparks | last post by:
well I am trying to get around looking at all the buttons with a case statement so I was trying this. Public Sub looking(ctlname) Dim ctl As OptionGroup Dim btn As ToggleButton ctl =...
0
7132
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7390
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
302
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.