Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6030351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:01:27+00:00 2026-05-23T05:01:27+00:00

i have this code written in php, and i want to convert it into

  • 0

i have this code written in php, and i want to convert it into python code

$title_regex = "/<title>(.+)<\/title>/i";
preg_match_all($title_regex, $string, $title, PREG_PATTERN_ORDER);
$url_title = $title[1];

/// fecth decription
$tags = get_meta_tags($url);

// fetch images
$image_regex = '/<img[^>]*'.'src=[\"|\'](.*)[\"|\']/Ui';
preg_match_all($image_regex, $string, $img, PREG_PATTERN_ORDER);
$images_array = $img[1];

i have tried this .. but it give me errors in pics part

import re
out=Data #web site html page ..
title_regex = "/<title>(.+)<\/title>/i" #no need for this .. un used 
m = re.search("<title>(.+)<\/title>", out)
print "title",m.group(1)
#for pics i have tried this but it give me error ..
pics = re.match(r"/<img[^>]*'.'src=[\"|\'](.*)[\"|\']/Ui", out)#the conversion is not correct  
print "grop",pics.group(1)

my full code

import re
import urllib
print "Start"
url="http://www.deviantart.com"
data=urllib.urlopen(url)
out=data.read()
print 
title_regex = "/<title>(.+)<\/title>/i"
m = re.search("<title>(.+)<\/title>", out)
print "first",m
print "title=",m.group(1)

title_regex = "/<title>(.+)<\/title>/i"

pics = re.match(r"/<img[^>]*src=[\"|\'](.*)[\"|\']/Ui", out)

print "pics>>",pics.group(1)

how i can convert a php re>>”/]*’.’src=\”|\'[\”|\’]/Ui” to a python re ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:01:28+00:00Added an answer on May 23, 2026 at 5:01 am

    the regular expression probably did not find anything.

    try this :
    also remove the /Ui at the end

    import re
    out=Data #web site html page ..
    title_regex = "/<title>(.+)<\/title>/i" #no need for this .. un used 
    if m is not None:  #  NEW  <----------------
       m = re.search("<title>(.+)<\/title>", out)
    print "title",m.group(1)
    #for pics i have tried this but it give me error ..
    pics = re.match(r"<img[^>]*src=[\"|\'](.*)[\"|\']", out)
    if pics is not None: # NEW <----------------
       print "grop",pics.group(1)
    

    for you 2nd question try this

    for filename in pics.groups():
        print filename
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written this code to convert string in such format 0(532) 222 22
I have all written code and i want to this code standarise by php
I have written a PHP Script, I run the code like this on MS-DOS
i am using ajax with jquery .i have written this code: $.ajax({url:myurl.php, data:datastr, type:POST,
I have this piece of code written in jQuery and PHP: <script type=text/javascript> $(document).ready(function(){
I have this code written in .NET 4.0 using VS2010 Ultimate Beta 2: smtpClient.Send(mailMsg);
I have written this code to join ArrayList elements: Can it be optimized more?
I have this code in my ASP.NET application written in C# that is trying
In our application, I have seen code written like this: User.java (User entity) public
This is similar to this question, except the code is already written. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.