Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing two different html sources and combining the output
    primarykey
    data
    text
    <p>I am parsing two different html sources (one spits out "data A,B,C,D, and E" and the other spits out "data F") with two different scripts. I want to combine the output of both of these scripts into a simple csv format.</p> <p>I am trying to run a 3rd script that imports everything from the other two scripts and prints out the data. This is what I am doing to try and make this happen:</p> <pre><code>#!usr/bin/env python from script1 import * from script2 import * for c in cities : c.retrieveTemps() print(c.name,c.high0,c.low0,c.high1,c.low1,c.weather0,c.weather1,c.wind0,c.wind1) </code></pre> <p>All the variables are defined in script1 and script2. Script1 finds every variable except for c.wind1. However, when I run the above code, it will only find the data for either script1 OR script2 (depending on which one I import second), not both.</p> <p>Any ideas on what I can do to get it to print out all the data from both script1 and script2? Thanks!</p> <p><strong>EDIT</strong></p> <p>This is from script1:</p> <pre><code>#!usr/bin/env python import re import urllib from datetime import datetime from datetime import timedelta date = datetime.now() date1 = date + timedelta(days=1) date2 = date + timedelta(days=2) class city : def __init__(self, city_name, link) : self.name = city_name self.url = link self.wind1 = 0 def retrieveTemps(self) : filehandle = urllib.urlopen(self.url) # get lines from result into array lines = filehandle.readlines() # (for each) loop through each line in lines line_number = 0 # a counter for line number for line in lines: line_number = line_number + 1 # increment counter # find string, position otherwise position is -1 position2 = line.rfind('&lt;ul class="stats"&gt;') #String is found in line if position2 &gt; 0 : self.wind0 = lines[line_number + 1].split('&lt;/strong&gt;')[0].split('style=""&gt;')[-1] break # done with loop, break out of it return ('c.wind0') filehandle.close() m1 = city('Mexico City', 'http://www.accuweather.com/en/mx/mexico-city/242560/daily-weather-forecast/242560?day=2') m3 = city('Veracruz', 'http://www.accuweather.com/en/mx/veracruz/236233/daily-weather-forecast/236233?day=2') m5 = city('Tampico', 'http://www.accuweather.com/en/mx/tampico/235985/daily-weather-forecast/235985?day=2') m7 = city('Nuevo Laredo', 'http://www.accuweather.com/en/mx/nuevo-laredo/235983/daily-weather-forecast/235983?day=2') m9 = city('Monterrey', 'http://www.accuweather.com/en/mx/monterrey/244681/daily-weather-forecast/244681?day=2') m11 = city('S. Luis Potosi', 'http://www.accuweather.com/en/mx/san-luis-potosi/245369/daily-weather-forecast/245369?day=2') m13 = city('Queretaro', 'http://www.accuweather.com/en/mx/queretaro/245027/daily-weather-forecast/245027?day=2') m15 = city('Laz. Cardenas', 'http://www.accuweather.com/en/mx/lazaro-cardenas/239054/daily-weather-forecast/239054?day=2') cities = [] cities.append(m1) cities.append(m3) cities.append(m5) cities.append(m7) cities.append(m9) cities.append(m11) cities.append(m13)) cities.append(m15) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload