Вопрос

I need to extract all links (URLs) from a database. Either, using a SQL statement or Python, how can I extract just links from a table?

Sometimes there is no links, sometime 1 and sometime more than 1.

To give an example:

Database name (dbase) Tables: id ( int) col1 ( has text including URLs) col2 ( has text including URLs) col3 ( has text including URLs) col4 ( has text including URLs)

col1, col2, col3 and col4 contain texts and URLs. (imagen an email contain URLs)

I want to create a new coloum name for example name (URL_found) to have all the URLs found in the col1, col2, col3 and col4.

example

in col1 has Hello, Hi this is a test http://www.example.com/somewhereelse/some/where if you buy this I will get you a free one form

Any idea on how to do that?

THANKS --

Нет правильного решения

Другие советы

This is a broad question, so here is a broad suggestion. You might need to iterate through the records in your table with a python client, and parse the strings in each column for valid urls, using either a regular expression or some other python parsing library.

Once you find matches for a column or record, you could set them to another column URL_found with some kind of delimiter between urls...but it would seem to be more useful to create a new db table like URL_found with foreign key relations to the records in this original table.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top