Jump to content

Find url before string


Recommended Posts

Hi everyone

I'm trying to find youtube url from "my videos" page. HTML code looks like:

<div class="ytg-box">
          <div class="vm-video-title">
      <a href="/watch?v=1y7Q0xHz2nM" >testowanko_4</a>
        <img class="vm-video-badge" src="//s.ytimg.com/yt/img/hd_video_result_page_logo-vfl3u0IPG.png" />
  </div>

        <span class="vm-video-info">
                17 lipiec 2011, 01:07 (PDT)

            <span class="vm-separator">|</span>
                <div class="yt-uix-hovercard vm-inline">
        <span class="vm-video-desc yt-uix-hovercard-target">Uploaded with Free Video Converter from Freemake
http://www.fr...</span>

My programm should find string "Uploaded with Free Video Converter from Freemake" and find url of video with this description. The problem is that 'testowanko_4' is the title and can be random length, source of image also and everything in link after '/watch?v=' also can be random length.

I'm sitting on that from yesterday and no idea how to do that...

I hope that everything is clear :)

Could someone help me?

Smigacznr1

Link to comment
Share on other sites

Use _StringBetween($variable,'<a href="/watch?v=','</a>') and then use StringInStr() function to detect char > and know where start your result (in your case testowanko_4). Then a simple StringTrimLeft() or StringRight() depending on how you call StringInStr() will give you the desired result.

Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

Thanks fo replay but it's no so simple.... In your cases functions will show all links with 'watch?=blabla' but it's not correct. On 'my videos' subpage user can have many of videos included that one without description 'Uploaded with Free Video Converter from'.

The problem is to find exactly this description and url of video with this description. In html before this kind of video and after can be videos without this description.

For now I have:

Func zamykanie()
    if $success = True Then
        $oIE = _IECreate ("https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Dpl_PL%26next%3D%252F&hl=pl_PL&ltmpl=sso", 0, 1, 1, 0)
        Send("login{TAB}pass{ENTER}")
        _IELoadWait ($oIE)
        _IENavigate ($oIE, "http://www.youtube.com/my_videos?feature=mhee")
        _IELoadWait ($oIE)
        $sHTML = _IEDocReadHTML ($oIE)
If $sHTML = StringRegExp('"<span class="vm-video-desc yt-uix-hovercard-target">Uploaded with Free Video Converter"', '<a href=(.*)', 1) Then

;and what now....

MsgBox(0, "title", $1HTML)
endif

Any next ideas?

Link to comment
Share on other sites

Mistake, sorry guys. I have to find name of video and name of edit button in code:

<div class="ytg-box">
          <div class="vm-video-title">
      <a href="/watch?v=y7dt6jK5tho" >TITLE OF VIDEO</a>
  </div>

        <span class="vm-video-info">
                17 lipiec 2011, 06:31 (PDT)

            <span class="vm-separator">|</span>
                <div class="yt-uix-hovercard vm-inline">
        <span class="vm-video-desc yt-uix-hovercard-target">Uploaded with Free Video Converter from Freemake
http://www.fr...</span>
        <span class="yt-uix-hovercard-content">Uploaded with Free Video Converter from Freemake
http://www.freemake.com/free_video_converter/</span>
      </div>

        </span>
        <span class="vm-video-info">
        </span>
            <span class="vm-video-info">
      

      

      

        


      <span class="yt-uix-button-group"><button name="49616900812" onclick=";return false;" type="button" class="start vm-playlist-edit-video yt-uix-button yt-uix-button-short"  role="button" aria-pressed="false"><span class="yt-uix-button-content">Edytuj

Title in code is 'TITLE OF VIDEO' of course and

name of edit button will be '49616900812' in this case. We have to remember that title, name of button can be different for every video, we don't know length also...

Also we don't know text between name of button and title of video.

That shuld work like this:

Script search description 'Uploaded with Free Video Converter from Freemake' (that's only constant part what we know) when found is searching for video title and save in var $title, next search for name of button 'Edytuj' (html name of this button is '49616900812' in this case). Next I'll navigate by this button and do next things. I don't know how to do this search part and how to get this names...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...