parsing table with BeautifulSoup and write in text file

前端 未结 2 1210
遥遥无期
遥遥无期 2021-02-03 11:57

I need data from table in text file (output.txt) in this format: data1;data2;data3;data4;.....

Celkova podlahova plocha bytu;33m;Vytah;Ano;Nadzemne podlazie;Prizemne pod

2条回答
  •  离开以前
    2021-02-03 12:47

    here's an alternative non BS way, just for your task

    store=[] #to store your results
    url="""http://www.reality.sk/zakazka/0747-003578/predaj/1-izb-byt/kosice-mestska-cast-sever-sladkovicova-kosice-sever/art-real-1-izb-byt-sladkovicova-ul-kosice-sever"""
    page=urllib2.urlopen(url)
    data=page.read()
    for table in data.split(""):
        if ""):
                  if "")[-1].strip())
    print ','.join(store)
    

    output

    $ ./python.py
    Celková podlahová plocha bytu,33 m2,Výťah,Áno,Nadzemné podlažie,Prízemné podlažie,Stav,Čiastočná rekonštrukcia,Konštrukcia bytu,tehlová,Forma vlastníctva,osobné
    

提交回复
热议问题