Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!border2.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; ';-)': 0.03; 'elif': 0.05; 'python)': 0.05; '(using': 0.07; 'python3': 0.07; 'sys': 0.07; 'false,': 0.09; 'received:209.85.219': 0.09; 'python': 0.11; '(may': 0.16; 'one)': 0.16; 'opposite': 0.16; 'skip:/ 60': 0.16; 'soup': 0.16; 'wrote:': 0.18; 'examples': 0.20; '(the': 0.22; 'example': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'pages,': 0.22; 'to:name:python-list@python.org': 0.22; '31,': 0.24; 'skip:l 30': 0.24; 'source': 0.25; '>': 0.26; 'extension': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'gives': 0.31; 'easier': 0.31; 'requests': 0.31; '"': 0.31; 'subject:other': 0.31; 'url:python': 0.33; 'skip:# 10': 0.33; 'skip:b 30': 0.33; 'subject: (': 0.35; 'received:209.85': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'false': 0.36; 'url:listinfo': 0.36; 'doing': 0.36; 'url:org': 0.36; 'received:209': 0.37; 'jason': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'how': 0.40; 'break': 0.61; 'information': 0.63; 'refer': 0.63; 'more': 0.64; 'total': 0.65; 'land': 0.65; 'here': 0.66; 'beautiful': 0.68; 'to,': 0.72; 'square': 0.74; 'click': 0.77; 'feet.': 0.84; 'found?': 0.84; '2013': 0.98 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=vdGrWBDVTJ9bNcofZ7T5XX6zbwARoTqzk0bHFXApC8A=; b=KZ0Lck+mCSpWS2WNnC9QxOd02EvEP08ToySt7noJ4UAW1e13GJgxE8ML4s98k5UANy 2o5mJaVjMu9wdE8tMW3clAfWW1ikt/aqyP7tywNwW544amYVpn2M6aXBPAtjdCkoIc8v ako4S/QNfcy7XqQOvB+jz4ckZzf+l2YR5IbhEsW5dNuLKYqImGxAtMqgvMUUnM4nTPB9 vkCwWO765g1OJlnJfTeDSG2y15UWPgxbwQ+/uDtSGgVT3ewMBbcm7B9LqIG8KT9yCwmU MwnybHrIgPLHd2GOneIBmLXvi453lafuYv05qxz1DiFmcfekoKl+p7S1A/yfnHfaeE0t 5TdQ== X-Gm-Message-State: ALoCoQl7Oct+VhKkhSGgPJsJAdq0A0bRq1hpOqtd/ucHR/NhQdEIilylemXiqttoqH2q+dIh+T3k X-Received: by 10.60.98.101 with SMTP id eh5mr20454oeb.53.1388555266921; Tue, 31 Dec 2013 21:47:46 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: From: Vincent Davis Date: Tue, 31 Dec 2013 22:47:26 -0700 Subject: Re: lookup xpath (other?) to value in html To: "python-list@python.org" Content-Type: multipart/alternative; boundary=089e0116167e6faaad04eee2373e X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 161 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1388558907 news.xs4all.nl 2851 [2001:888:2000:d::a6]:40042 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62950 --089e0116167e6faaad04eee2373e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable > > Which Chrome extension are you using to get that path? Built in, right click on source > copy xpath=E2=80=8B=E2=80=8B Ya that gets square footage and I like how you did it, are you interested in doing that for all information on the page and also the historical pages ;-) Since I have the data for some of the pages, I got this from the county on a cd, I thought defining the xpath would be easier using bs4 or http://lxml.de/ Vincent Davis 720-301-3003 On Tue, Dec 31, 2013 at 10:30 PM, Jason Friedman wrote= : > > For example this URL; > > http://jeffco.us/ats/displaygeneral.do?sch=3D001690 > > The the land sqft is 11082. > > Google Chrome gives me the xpath to that data as; > > //*[@id=3D"content"]/p[1]/table[4]/tbody/tr[2]/td[8] > > > > What I would like to do (using python) is given 11082 at what xpath can > that > > be found? (may be more that one) > > The examples I can find using google refer to, given xpath what is the > value > > (the opposite of what I want) > > Which Chrome extension are you using to get that path? > > Are you always interested in the square footage? Here is a solution > using Beautiful Soup: > > $ cat square-feet.py > #!/usr/bin/env python > import bs4 > import requests > import sys > url =3D sys.argv[1] > request =3D requests.get(url) > soup =3D bs4.BeautifulSoup(request.text) > is_sqft_mark_found, is_total_mark_found =3D False, False > for line in soup.get_text().splitlines(): > if line.startswith("Land Sqft"): > is_sqft_mark_found =3D True > continue > elif is_sqft_mark_found and line.startswith("Total"): > is_total_mark_found =3D True > continue > elif is_total_mark_found: > print(line.strip() + " total square feet.") > break > > $ python3 square-feet.py http://jeffco.us/ats/displaygeneral.do?sch=3D001= 690 > 11082 total square feet. > -- > https://mail.python.org/mailman/listinfo/python-list > --089e0116167e6faaad04eee2373e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Which Chrome extension are you using to = get that path?
Built in, right click on source > copy xpath=E2=80=8B=E2=80= =8B

Ya that gets square footage and I like how you did it, are= you interested in doing that for all information on the page and also the = historical pages ;-)
Since I have the data for some of the pages, I got this from the= county on a cd, I thought defining the xpath would be easier using bs4 or= =C2=A0http://lxml.de/




Vinc= ent Davis
720-301-3003


On Tue, Dec 31, 2013 at 10:30 PM, Jason = Friedman <jsf80238@gmail.com> wrote:
> For example this URL;
> http://jeffco.us/ats/displaygeneral.do?sch=3D001690
> The the land sqft is 11082.
> Google Chrome gives me the xpath to that data as;
> //*[@id=3D"content"]/p[1]/table[4]/tbody/tr[2]/td[8]
>
> What I would like to do (using python) is given 11082 at what xpath ca= n that
> be found? (may be more that one)
> The examples I can find using google refer to, given xpath what is the= value
> (the opposite of what I want)

Which Chrome extension are you using to get that path?

Are you always interested in the square footage? =C2=A0Here is a solution using Beautiful Soup:

$ cat square-feet.py
#!/usr/bin/env python
import bs4
import requests
import sys
url =3D sys.argv[1]
request =3D requests.get(url)
soup =3D bs4.BeautifulSoup(request.text)
is_sqft_mark_found, is_total_mark_found =3D False, False
for line in soup.get_text().splitlines():
=C2=A0 =C2=A0 if line.startswith("Land Sqft"):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 is_sqft_mark_found =3D True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 continue
=C2=A0 =C2=A0 elif is_sqft_mark_found and line.startswith("Total"= ):
=C2=A0 =C2=A0 =C2=A0 =C2=A0 is_total_mark_found =3D True
=C2=A0 =C2=A0 =C2=A0 =C2=A0 continue
=C2=A0 =C2=A0 elif is_total_mark_found:
=C2=A0 =C2=A0 =C2=A0 =C2=A0 print(line.strip() + " total square feet.&= quot;)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 break

$ python3 square-feet.py http://jeffco.us/ats/displaygeneral.do?sch= =3D001690
11082 total square feet.
--
https://mail.python.org/mailman/listinfo/python-list

--089e0116167e6faaad04eee2373e--