How to extract certain parts of a web page in Python

2024/11/17 5:27:21

Target web page: http://www.immi.gov.au/skilled/general-skilled-migration/estimated-allocation-times.htm

The section I want to extract:

  <tr><td>Skilled &ndash; Independent (Residence) subclass 885<br />online</td><td>N/A</td><td>N/A</td><td>N/A</td><td>15 May 2011</td><td>N/A</td></tr>

Once the code finds this section by searching the keyword "subclass 885
online
", it should then print the date which is within the 5th tag which is "15 May 2011" as shown above.

It's just a monitor for myself to keep an eye on the progress of my immigration application.

Answer

"Beau--ootiful Soo--oop!

Beau--ootiful Soo--oop!

Soo--oop of the e--e--evening,

Beautiful, beauti--FUL SOUP!"

--Lewis Carroll, Alice's Adventures in Wonderland

I think this is exactly what he had in mind!

The Mock Turtle would probably do something like this:

>>> from BeautifulSoup import BeautifulSoup
>>> import urllib2
>>> url = 'http://www.immi.gov.au/skilled/general-skilled-migration/estimated-allocation-times.htm'
>>> page = urllib2.urlopen(url)
>>> soup = BeautifulSoup(page)
>>> for row in soup.html.body.findAll('tr'):
...     data = row.findAll('td')
...     if data and 'subclass 885online' in data[0].text:
...         print data[4].text
... 
15 May 2011

But I'm not sure it would help, since that date has already passed!

Good luck with the application!

https://en.xdnf.cn/q/71257.html

Related Q&A

Accessing axis or figure in python ggplot

python ggplot is great, but still new, and I find the need to fallback on traditional matplotlib techniques to modify my plots. But Im not sure how to either pass an axis instance to ggplot, or get one…

Importing the same modules in different files

Supposing I have written a set of classes to be used in a python file and use them in a script (or python code in a different file). Now both the files require a set of modules to be imported. Should t…

Manually calculate AUC

How can I obtain the AUC value having fpr and tpr? Fpr and tpr are just 2 floats obtained from these formulas:my_fpr = fp / (fp + tn) my_tpr = tp / (tp + fn) my_roc_auc = auc(my_fpr, my_tpr)I know thi…

Plotly: How to make stacked bar chart from single trace?

Is it possible to have two stacked bar charts side by side each of them coming from a single column?Heres my df:Field IssuePolice Budget cuts Research Budget cuts Police Time consum…

zip function help with tuples

I am hoping someone can help me with a problem Im stuck with. I have a large number of tuples (>500) that look like this:(2,1,3,6) (1,2,5,5) (3,0,1,6) (10,1,1,4) (0,3,3,0) A snippet of my c…

Mini batch training for inputs of variable sizes

I have a list of LongTensors, and another list of labels. Im new to PyTorch and RNNs so Im quite confused as to how to implement minibatch training for the data I have. There is much more to this data,…

Python gTTS, is there a way to change the speed of the speech

It seems that on gTTS there is no option for changing the speech of the text-to-speech apart from the slow argument. I would like to speed up the sound by 5%. Any suggestion on how I can do it? Best.t…

Change QLabel text dynamically in PyQt4

My question is: how can I change the text in a label? The label is inside a layout, but setText() does not seem to work - maybe I am not doing it right. Here is my code:this is the Main windows GUI, t…

Setting figure size to be larger than screen size in matplotlib

Im trying to create figures in matplotlib that read nicely in a journal article. I have some larger figures (with subfigures) that Id like to take up nearly an entire page in portrait mode (specificall…

Tensorflow 0.7.1 with Cuda Toolkit 7.5 and cuDNN 7.0

I recently tried to upgrade my Tensorflow installation from 0.6 to 0.7.1 (Ubuntu 15.10, Python 2.7) because it is described to be compatible with more up-to-date Cuda libraries. Everything works well i…