Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62950
| 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 | <vincent@vincentdavis.com> |
| 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 | <CANy1k1i=F6dZ-UKyg52eMB3P9Y+T9e9707_wfQp_2BFvyqLU9g@mail.gmail.com> |
| References | <CALyJZZXtwD=PKjnnOiAcm3TF6RJZVqjsZCqupooEb8YNBNVoGA@mail.gmail.com> <CANy1k1g6Ws4G2WkPaZDAm14cN9NESUNqhNk4O-jzctxp9TRCJQ@mail.gmail.com> <CALyJZZWBozyDRe7c7hVRExw_V9KSAPQ2+LWjnfkcAo4C2J-rew@mail.gmail.com> <CANy1k1i=F6dZ-UKyg52eMB3P9Y+T9e9707_wfQp_2BFvyqLU9g@mail.gmail.com> |
| From | Vincent Davis <vincent@vincentdavis.net> |
| Date | Tue, 31 Dec 2013 22:47:26 -0700 |
| Subject | Re: lookup xpath (other?) to value in html |
| To | "python-list@python.org" <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 <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4774.1388558907.18130.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
>
> Which Chrome extension are you using to get that path?
Built in, right click on source > copy xpath
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 <jsf80238@gmail.com> wrote:
> > For example this URL;
> > http://jeffco.us/ats/displaygeneral.do?sch=001690
> > The the land sqft is 11082.
> > Google Chrome gives me the xpath to that data as;
> > //*[@id="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 = sys.argv[1]
> request = requests.get(url)
> soup = bs4.BeautifulSoup(request.text)
> is_sqft_mark_found, is_total_mark_found = False, False
> for line in soup.get_text().splitlines():
> if line.startswith("Land Sqft"):
> is_sqft_mark_found = True
> continue
> elif is_sqft_mark_found and line.startswith("Total"):
> is_total_mark_found = 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=001690
> 11082 total square feet.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: lookup xpath (other?) to value in html Vincent Davis <vincent@vincentdavis.net> - 2013-12-31 22:47 -0700
csiph-web