[Python] BeautifulSoup tags > </a>

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
Top Forums Programming [Python] BeautifulSoup tags > </a>
# 1  
[Python] BeautifulSoup tags > </a>

using BeautifulSoup
how can i get the txt between all the

> </a>

>The Student [2017].mp4</a>

# 2  
Are you using BeautifulSoup 3 or BeautifulSoup 4?

Beautiful Soup Documentation — Beautiful Soup 4.4.0 documentation

Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. It commonly saves programmers hours or days of work.

These instructions illustrate all major features of Beautiful Soup 4, with examples. I show you what the library is good for, how it works, how to use it, how to make it do what you want, and what to do when it violates your expectations.

The examples in this documentation should work the same way in Python 2.7 and Python 3.2.

You might be looking for the documentation for Beautiful Soup 3. If so, you should know that Beautiful Soup 3 is no longer being developed, and that Beautiful Soup 4 is recommended for all new projects. If you want to learn about the differences between Beautiful Soup 3 and Beautiful Soup 4, see Porting code to BS4.
# 3  
This should work, according to the docs (untested):

from bs4 import BeautifulSoup
markup = '<a href="https://unix.com/">The Student [2017].mp4</a>'
soup = BeautifulSoup(markup)

tag = soup.a
# The Student [2017].mp4

Tweak as you see fit .....


Beautiful Soup Documentation — Beautiful Soup 4.4.0 documentation
# 4  
hi thanks for reply

your code did not work

need to get all the txt between all of the > </a>

# 5  
Works fine for me:

linux:/tmp# python p.py
The Student [2017].mp4

linux:/tmp# cat p.py
from bs4 import BeautifulSoup
markup = '<a href="https://unix.com/">The Student [2017].mp4</a>'
soup = BeautifulSoup(markup, 'lxml')

tag = soup.a
print tag.string
# The Student [2017].mp4

My goal was to show the way to do it; but you can do things like add print statements in python for yourself Smilie
# 6  
so your saying that will get me all

the txt between all of the > </a>

on the page not just one

as there are about 200 of them all with different txt between them

# 7  
I am saying you have not written or posted a single line of code here; nor have you posted a single error message.

Are you expecting us to write your entire code for you?

Read the docs for you? Do all your work for you?

If so, you have come to the wrong place, sorry.

We are here to help you write your own code.

So far, I have written more code than you on this.... LOL .

You have not provided us a single line of YOUR OWN python code.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #288
Difficulty: Easy
In Linux, Logical Volume Manager (LVM) is a device mapper target that provides sound card I/O management for the Linux kernel.
True or False?

9 More Discussions You Might Find Interesting

1. Programming

Create a C source and compile inside Python 1.4.0 to 3.7.0 in Python for ALL? platforms...

Hi all... As you know I like making code backwards compatible for as many platforms as possible. This Python script was in fact dedicated for the AMIGA A1200 using Pythons 1.4.0, 1.5.2, 1.6.0, 2.0.1, and 2.4.6 as that is all we have for varying levels of upgrades from a HDD and 4MB FastRam... (1 Reply)
Discussion started by: wisecracker
1 Replies

2. Windows & DOS: Issues & Discussions

How to execute python script on remote with python way..?

Hi all, I am trying to run below python code for connecting remote windows machine from unix to run an python file exist on that remote windows machine.. Below is the code I am trying: #!/usr/bin/env python import wmi c = wmi.WMI("xxxxx", user="xxxx", password="xxxxxxx")... (1 Reply)
Discussion started by: onenessboy
1 Replies

3. Shell Programming and Scripting

Python BeautifulSoup Re Finding Digits Within Tags

I am writing a little python script that needs to grab version numbers between "<td>4.2.2</td>" within the tbody of the page: blah blah blah blah blah Is it possible to use a one-liner to scrap only the digits between the tags: "<td>4.2.2</td>" so it spits out: 4.2.2 4.2.1 etc..... (2 Replies)
Discussion started by: metallica1973
2 Replies

4. Shell Programming and Scripting

**python** unable to read the background color in python

I am working on requirement on spreadsheet in python scripting. I have a spreadsheet containing cell values and with background color. I am able to read the value value but unable to get the background color of that particular cell. Actually my requirement is to read the cell value along... (1 Reply)
Discussion started by: giridhar276
1 Replies

5. UNIX for Dummies Questions & Answers


Hi all... Not sure where to put this so I put it here... All comments welcome... 1) Is the Python language now considered a part of the *NIX transient command structure much like Perl, (and awk)? 2) If so which OSes now have it as part of a "default" install - NOT an extra to be... (5 Replies)
Discussion started by: wisecracker
5 Replies

6. SuSE

"ssh suse-server 'python -V' > python-version.out" not redirecting

Okay, so I have had this problem on openSUSE, and Debian systems now and I am hoping for a little help. I think it has something to do with Python but I couldn't find a proper Python area here. I am trying to redirect the output of "ssh suse-server 'python -V'" to a file. It seems that no matter... (3 Replies)
Discussion started by: Druonysus
3 Replies

7. Programming

Help with Python. Please and thanks.

Hi everybody, I've been experimenting with Python lately and for the most part it's been a smooth ride. I have one little problem that maybe one of you can help me with. PROBLEM: I have list with one word per line. EXAMPLE apples oranges pears grapes etc... I also have a shell... (2 Replies)
Discussion started by: o0110o
2 Replies

8. Programming

Python: bash-shell-like less functionality in the python shell

Hello, Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells? Example: >>> import subprocess >>> help(subprocess) ... ... I'm hoping so as I hate scrolling and love how less works with... (0 Replies)
Discussion started by: Narnie
0 Replies

9. UNIX for Dummies Questions & Answers

Python Help

Hey can someone help me describe the path of my python to MS DOS so i can access the files through my command line? im running windows 98 obviously. In the editor for autoexec it shows that i have the correct path but what else must i do for it to work correctly? (1 Reply)
Discussion started by: MAdSAcRAfICe
1 Replies

Featured Tech Videos