Python Forum
HELP on Unwanted CSV Export Output | Using Selenium to Scrape
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HELP on Unwanted CSV Export Output | Using Selenium to Scrape
#1
Hi guys,

It's been a long time since my last post.

Anyway, I'm having trouble with the CSV export result on a website I am trying to scrape data from.

====================================

Output Problems:
Output in column but just the first column and it only output's the first column of data
[Image: b6Qhek6.png]

Output in rows but just one row
[Image: Imhh7HQ.png]

I just want it to output the typical way
[Image: Vmp6MHp.png]

====================================
Here's a segment of the whole site's html where my particular target is:
# My apology, I do not know how to wrap html in creating a thread and the button "Insert code snippet" doesn't work. <tbody id="sitesList">	<tr data-value="11230" class="item-row">	<td class="text-left"><a href="http://www.example.com" target="_blank">example.com</a> <i class="fa fa-external-link"></i>	<br><span>» <a href="https://www.domain.com/site/11230.html" target="_blank" class="text-danger">view site details</a></span></td>	<td>92</td>	<td>71</td>	<td>Do Follow</td>	<td style="font-size:12px;font-family:sans-serif !important;">Education	<br>Family &amp; Parenting	<br>Food &amp; Drink	<br>	</td>	<td>Included</td>	<td><strong>$1</strong></td>	<td><span data-id="11230" class="btn btn-success btn-sm addtocart">Buy Website $1</span></td>	</tr>	<tr data-value="11229" class="item-row">	<td class="text-left"><a href="http://example1.com/" target="_blank">example1.com</a> <i class="fa fa-external-link"></i>	<br><span>» <a href="https://www.domain.com/site/11229.html" target="_blank" class="text-danger">view site details</a></span></td>	<td>65</td>	<td>34</td>	<td>Do Follow</td>	<td style="font-size:12px;font-family:sans-serif !important;">Business &amp; Finance	<br>General: Multi-Niche	<br>	</td>	<td>Included</td>	<td><strong>$2</strong></td>	<td><span data-id="11229" class="btn btn-success btn-sm addtocart">Buy Website $2</span></td>	</tr>	<tr data-value="11228" class="item-row">	<td class="text-left"><a href="https://example2.com" target="_blank">example2.com</a> <i class="fa fa-external-link"></i>	<div class="tooltip owner_tooltip" style="float: right;opacity: 1;width: 20px;height: 20px;background-size: 100%;"><span class="tooltiptext">Owner Verified</span></div>	<br><span>» <a href="https://www.domain.com/site/11228.html" target="_blank" class="text-danger">view site details</a></span></td>	<td>27</td>	<td>26</td>	<td>Do Follow</td>	<td style="font-size:12px;font-family:sans-serif !important;">Cryptocurrency	<br>	</td>	<td>Not Included</td>	<td><strong>$3</strong></td>	<td><span data-id="11228" class="btn btn-success btn-sm addtocart">Buy Website $3</span></td>	</tr>	<tr data-value="11227" class="item-row">	<td class="text-left"><a href="https://example3.com" target="_blank">example3.com</a> <i class="fa fa-external-link"></i>	<br><span>» <a href="https://www.domain.com/site/11227.html" target="_blank" class="text-danger">view site details</a></span></td>	<td>23</td>	<td>29</td>	<td>Do Follow</td>	<td style="font-size:12px;font-family:sans-serif !important;">Business &amp; Finance	<br>Health	<br>SEO &amp; Digital Marketing	<br>	</td>	<td>Included</td>	<td><strong>$4</strong></td>	<td><span data-id="11227" class="btn btn-success btn-sm addtocart">Buy Website $4</span></td>	</tr> </tbody>
====================================

I'm using selenium and here's my code:
siteList_tds = driver.find_elements(By.XPATH, "//tbody[@id='sitesList']//tr//td") with open('test.csv', 'w') as f: write = csv.writer(f) for s in siteList_tds: write.writerow(s.text) ## or write.writerow([s.text])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  data input while debugging causes unwanted code completion fred1232 2 2,592 Sep-14-2025, 03:32 PM
Last Post: deanhystad
  How to remove unwanted images and tables from a Word file using Python? rownong 2 2,156 Feb-04-2025, 08:30 AM
Last Post: Pedroski55
Question Unwanted execution of unittest ThomasFab 9 6,192 Nov-15-2022, 05:33 PM
Last Post: snippsat
Question Export Python output to Excel skyline1397 1 3,906 Jun-26-2022, 05:10 AM
Last Post: skyline1397
  Removing the unwanted data from a file jehoshua 14 8,484 Feb-01-2022, 09:56 PM
Last Post: jehoshua
  How to scrape and count star rating using Selenium and Python? celinafregoso99 1 4,665 Feb-15-2021, 02:45 PM
Last Post: kashcode
  How to eliminate unwanted spaces Mohan 5 5,278 Jun-04-2020, 08:34 AM
Last Post: buran
  export sql output to excel Kranthi 6 10,974 Oct-17-2018, 02:01 AM
Last Post: Kranthi
  Unwanted delay between looped synth plays WolfeCreek 1 3,344 Aug-02-2018, 09:24 PM
Last Post: Vysero
  Unwanted variable change in module dannyH 2 4,067 May-08-2018, 05:33 PM
Last Post: dannyH

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.