Jump to content
UBot Underground

How To Save Multiple Columns To Csv


Recommended Posts

I'm not sure what I'm missing but when the bot I'm working on saves to CSV the items go into all different rows.

 

What I'm looking to do is have it in 3 columns.  So title would be in column 1, description in column 2, picture in column 3.  Then each row would be what was scraped off of the page.  I have the scraping working, I just can't figure out how to make everything in a neat output.

 

I also played around with tables but I got the same result.  I probably messed it up since I never used the tables option before and deleted it.  I've attached a picture of what my setup is now.

 

What am I doing wrong here?

 

I appreciate any help I can get.  Thanks.

post-8944-0-73448100-1501117158_thumb.png

  • Like 1
Link to post
Share on other sites

When you want to scrape several items per ad (or whatever it may be) what you want to do it scrape each item individually and insert it into a table cell. I've seen people try to scrape lists of things and think they can just combine them at the end but you will often find this leads to problems because sometimes ads may not have a description or a picture or perhaps it has more than one and it messes up the offset when you combine them at the end and so it gives you invalid data.

 

So what you want to do is to scrape each little item individually and insert it into a table cell, here is an example of what I'm talking about:

navigate("https://houston.craigslist.org/search/rva","Wait")
clear list(%adContainers)
add list to list(%adContainers,$scrape attribute(<class="result-row">,"outerhtml"),"Don\'t Delete","Global")
set(#row,0,"Global")
clear table(&ads)
loop($list total(%adContainers)) {
    set(#ad,$next list item(%adContainers),"Global")
    set(#title,$plugin function("XpathPlugin.dll", "$Generic Xpath Parser", #ad, "//a[@class=\'result-title hdrlnk\']", "innertext", ""),"Global")
    set table cell(&ads,#row,0,#title)
    set(#price,$plugin function("XpathPlugin.dll", "$Generic Xpath Parser", #ad, "//span[@class=\'result-price\']", "innertext", ""),"Global")
    set table cell(&ads,#row,1,#price)
    set(#location,$plugin function("XpathPlugin.dll", "$Generic Xpath Parser", #ad, "//span[@class=\'result-hood\']", "innertext", ""),"Global")
    set table cell(&ads,#row,2,#location)
    increment(#row)
}
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...