Getting lxml to work for my Python scraping code
02:22 14 Sep 2014

I am scraping using lxml. I just made a code that is working fine but I have two problems.

1. I want name and address in same row and every entry should be in different line like

    name1,adress1
    name2,adress2

I don't need any square bracket in the data.

2. I have to enter 500 codes so I want to import it from external text/csv file. How can I do it?

import lxml.html as lh

from selenium import webdriver

browser = webdriver.Firefox()

from lxml import html


for cod in ("35211","36116","36542"):
    
     browser.get('http://kmbsapps.konicaminolta.us/wheretobuy/main_search.jspx?productCategory=Office+Systems&sl_zip='+cod)
    
     content = browser.page_source
    
     tree = lh.fromstring(content)
    
     name=tree.xpath('//tr/td/span[@class="largecol"]/text()')
    
     adress=tre.xpath('//tr/td/span[@class="smallcol"]/text()')
    

     print(name,adress)
python selenium web-scraping lxml