Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62946
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jsf80238@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.014 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'elif': 0.05; 'python)': 0.05; '(using': 0.07; 'python3': 0.07; 'sys': 0.07; 'false,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '(may': 0.16; 'one)': 0.16; 'opposite': 0.16; 'soup': 0.16; 'examples': 0.20; '(the': 0.22; 'example': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'extension': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'requests': 0.31; 'subject:other': 0.31; 'skip:# 10': 0.33; 'skip:b 30': 0.33; 'subject: (': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'false': 0.36; 'break': 0.61; 'refer': 0.63; 'more': 0.64; 'total': 0.65; 'land': 0.65; 'here': 0.66; 'beautiful': 0.68; 'to,': 0.72; 'square': 0.74; 'feet.': 0.84; 'found?': 0.84; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=rDZiyemwxwgNXFkPNtACiQ1oyFfmscHPnvSzAS3JG2s=; b=sMBiJ4eU1FpajAo6PLFxbxEOrEkH36dmO1hSU/YUb3LENfqnGfGTp+cy0El0HrEoVm W6RbQQb8vtnhJ8CTU24M6jo/opCx06ZLTPzhor8FBo75biGNJCEF97+qI7lewqvX5teN fw6SxomJS/6MjhY0i67QdA4TMAUYvU9YckMEj0R0GdOYFqEj7s3gaGzdExZ7e1lAeMJN Lm9SUP922c8y2sbvDk7KzNu3ua96BlOmsuXNFEf4Fs6e+fsR8pulsZQhsRI8SbqZZTzU m8u3C/QcVL5aovWlfHVRfLLM9LFxyoY9YHb5+s0KG2kgfHlJgo0s17N7RgEhD1xqbTc5 q2yw== |
| MIME-Version | 1.0 |
| X-Received | by 10.50.66.212 with SMTP id h20mr64969477igt.48.1388554238626; Tue, 31 Dec 2013 21:30:38 -0800 (PST) |
| In-Reply-To | <CALyJZZWBozyDRe7c7hVRExw_V9KSAPQ2+LWjnfkcAo4C2J-rew@mail.gmail.com> |
| References | <CALyJZZXtwD=PKjnnOiAcm3TF6RJZVqjsZCqupooEb8YNBNVoGA@mail.gmail.com> <CANy1k1g6Ws4G2WkPaZDAm14cN9NESUNqhNk4O-jzctxp9TRCJQ@mail.gmail.com> <CALyJZZWBozyDRe7c7hVRExw_V9KSAPQ2+LWjnfkcAo4C2J-rew@mail.gmail.com> |
| Date | Tue, 31 Dec 2013 22:30:38 -0700 |
| Subject | Re: lookup xpath (other?) to value in html |
| From | Jason Friedman <jsf80238@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| 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.4771.1388554247.18130.python-list@python.org> (permalink) |
| Lines | 38 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1388554247 news.xs4all.nl 2875 [2001:888:2000:d::a6]:58197 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62946 |
Show key headers only | View raw
> 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.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: lookup xpath (other?) to value in html Jason Friedman <jsf80238@gmail.com> - 2013-12-31 22:30 -0700
csiph-web