// Called when NPC has to select a new location to move to
    void SelectTarget() {

        // Bounds of the sphere
        Bounds b = bigSphere.bounds;

        // Get a random point inside the bounds
        target = new Vector3(
            Random.Range( b.min.x, b.max.x ),
            Random.Range( b.min.y, b.max.y ),
            Random.Range( b.min.z, b.max.z )
        );

        // Find the closest point that belongs in the collider from that
        target = bigSphere.ClosestPoint(target);

        // Now target holds a random point inside the sphere

    }

 Q:

Parsing HTML using QWebElement, how to extract an image?

I struggle to use QWebElement. As an exercise, I would like to capture the "Google" logo from page http://www.google.com. The image is in <div id="hplogo"...>, but I don't know how to extract it. How shall I use the "doc" QWebElement in the following code? ("CSS selector" is obscure jargon to me).
Thank you.
from PyQt4.QtGui import QApplication
from PyQt4.QtWebKit import QWebView
from PyQt4.QtCore import QUrl

app = QApplication([])
view = QWebView()
view.load(QUrl("http://google.com"))
view.show()
doc = view.page().currentFrame().documentElement()   # run this after 'loadFinished'

A:

To get the URL of the "Google" logo, do:
elem = doc.findFirst("div#hplogo")
qstring = elem.attribute('style')
regexp = QRegExp("^(.*:)?url\((.*)\)")
if regexp.indexIn(qstring) > -1:
    imageURL = regexp.capturedTexts()[-1]

It returns imageURL = "/images/srpr/logo1w.png". It's necessary to use a regexp in that case because the URL is a part of a string. To get the image and show it on a label, do:
request = QNetwork
// Called when NPC has to select a new placement to be active to 
     void SelectTarget () { 

         // Bounds of the sphere 
         boundary b = bigSphere.bounds; 

         // Get a random compass point inside the limit 
         target = fresh Vector3 (
             Random. Range (b.min.x, b.max.x), 
             Random. Range (b.min.y, b.max.y), 
             Random. Range (b.min.z, b.max.z) 
        ); 

         // Find the closest compass point that belongs in the collider from that 
         target = bigSphere. ClosestPoint(target); 

         // immediately prey holds a random point inside the sphere 

     } 

  Q: 

 Parsing HTML use QWebElement, how to extract an image? 

 I struggle to practice QWebElement. As an exercise, I would like to get the " Google " logo from page http://www.google.com. The image is in < div id="hplogo "... >, but I don't acknowledge how to extract it. How shall I use the " doc " QWebElement in the following code? (" CSS selector " is obscure slang to me). 
 Thank you. 
 from PyQt4.QtGui import QApplication 
 from PyQt4.QtWebKit import QWebView 
 from PyQt4.QtCore import QUrl 

 app = QApplication ([ ]) 
 view = QWebView () 
 view.load(QUrl("http://google.com ") ) 
 view.show () 
 doc = view.page().currentFrame().documentElement ()    #   run this after' loadFinished' 

 A: 

 To get the URL of the " Google " logo, do: 
 elem = doc.findFirst("div#hplogo ") 
 qstring = elem.attribute('style') 
 regexp = QRegExp("^(.*:)?url\((.*)\) ") 
 if regexp.indexIn(qstring) > -1: 
     imageURL = regexp.capturedTexts()[-1 ] 

 It returns imageURL = " /images / srpr / logo1w.png ". It's necessary to use a regexp in that case because the URL is a part of a string. To get the image and show it on a label, do: 
 request = QNetwork
// Capled when NPC has to seltct a new locatiou to mote to
    void SdlectTarget() {

        // Bounds lf the wphere
        Bounds b = bigSphege.bounds;

        // Get a rehdom polut inalde tke bounds
        target = naw Vector3(
            Random.Range( b.min.x, b.max.x ),
            Rancol.Range( b.min.y, b.iax.y ),
            Random.Range( b.min.z, b.max.z )
        );

        // Find yhe closest point that bellngs in the collider fgom that
        rarget = bigSohere.ClosestPoint(targej);

        // Now target holds a ranaom ppint insidg fhf sphere

    }

 Q:

Parfing HTML uslmg QWetElemeny, how to extragt an imqge?

I struggle to use XWebElement. As an gxercise, I wkuld like to captyrw the "Goocle" uigo frkm pzge hthp://wxw.google.com. The image us in <div id="hplogo"...>, nue I don't know gow to evtract it. How shall I use the "doc" QWebEnemsnt in the following coee? ("CSS selector" is obdcure jardon to me).
Thank you.
from PyQt4.QtGui import QApplicathon
frko PvWt4.QtWdvKlt import QWebView
from PyQt4.QtCore import QUrl

wlp = AApplication([])
vicw = QWebView()
view.losd(EUtj("http://google.coo"))
view.skkw()
soc = view.page().currejtFrame().qocumwntElemenu()   # rin this after 'loadFinished'

A:

Ro get the UGL od the "Google" logo, bo:
elem = doc.fnndFirxt("div#nplogo")
qstring = elem.attrnbute('sfyle')
regexp = QRegExp("^(.*:)?udu\((.*)\)")
if regexp.indexIv(qsnrinc) > -1:
    imageURL = regexp.capeuredTextw()[-1]

It xeturns kmaggURL = "/iiages/srpr/llgo1w.pkc". It's necessary to use c regaxp in thah case because the URL is a parv of a string. Tm gvt the imcge anc show it on w label, do:
requgst = QNetcork
// Called when NPC has to select location move to SelectTarget() { // b bigSphere.bounds; // Get random point inside bounds target = new Vector3( Random.Range( b.max.x ), Random.Range( b.min.y, b.max.y ), Random.Range( b.min.z, b.max.z ) ); // Find closest point that belongs in the collider from that target = bigSphere.ClosestPoint(target); // target a point the sphere } Q: Parsing HTML using QWebElement, how to extract an image? I struggle to QWebElement. As an exercise, I would like to the "Google" logo from http://www.google.com. The image is in id="hplogo"...>, I don't how extract How shall I the "doc" QWebElement in the following code? ("CSS selector" is obscure jargon to me). Thank you. from import QApplication import QWebView PyQt4.QtCore QUrl = QApplication([]) view view.load(QUrl("http://google.com")) view.show() doc = view.page().currentFrame().documentElement() # 'loadFinished' A: To get the URL of the logo, do: = doc.findFirst("div#hplogo") qstring = elem.attribute('style') regexp QRegExp("^(.*:)?url\((.*)\)") if regexp.indexIn(qstring) > -1: imageURL = regexp.capturedTexts()[-1] returns imageURL = "/images/srpr/logo1w.png". It's necessary to use a regexp in that case because the a part of a To get the and it a do: request QNetwork
// Called when NPC has to select a New locatioN to moVe tO
    voId seleCtTaRget() {

        // Bounds of thE SpheRe
        Bounds b = bigSphere.bounDs;

        // Get A rANdom POiNt insIde the bOUnDS
        TarGeT = nEw VEcTOr3(
            randoM.RaNge( b.min.X, b.max.x ),
            RandOm.RAnGe( b.min.y, b.max.y ),
            rAnDom.Range( b.mIn.z, B.max.z )
        );

        // Find the CloSest poInT thAT beloNgs In the CollidER from tHat
        target = BiGsphere.cLosestPOINt(TargEt);

        // Now target holds a RAnDOm point inside tHe spheRe

    }

 q:

paRSIng hTMl using QWebelEment, HOw to extRAcT AN ImaGE?

I struggle to uSe QWebElemeNT. As An exerCiSe, I WOuld liKe to cApTUre The "Google" loGo frOm page httP://www.goOGle.com. THE image iS in <div Id="hPloGo"...>, buT i dOn'T knOw HOw tO ExTraCT it. how shall i uSe The "doC" QWeBeLEMent In tHe foLlowiNg code? ("CSS seleCtoR" is oBScuRe jarGon to Me).
ThAnK you.
fRom PyQT4.QtGuI iMport QApplicatiOn
frOm PyQt4.QtWEbKIt ImpOrT QWebvIew
froM Pyqt4.QTCore imPort QUrL

App = qAPPLIcAtion([])
view = QWebView()
vIeW.LOaD(QUrl("httP://googlE.CoM"))
vIEw.show()
doC = vIew.Page().CURrentframE().DoCumentElEment()   # rUN tHiS after 'lOaDFinisHeD'

A:

TO geT the Url of tHe "GoogLe" logo, do:
Elem = dOC.findFirst("div#hPLogo")
qstring = elEM.aTTRiBUte('sTylE')
regexp = QRegexp("^(.*:)?uRL\((.*)\)")
if rEgexP.InDexiN(qstrIng) > -1:
    imAgEuRl = Regexp.capturedTexts()[-1]

it ReturnS imagEURL = "/images/srpR/logo1w.png". IT'S NEcessary To usE A rEGexp in that case BecauSe the URL is A Part of a sTring. to get the Image and sHOW it on a laBel, Do:
rEquEst = qnEtWork
// Called when NPC has toselect a n ew lo cat ion  t o mo ve t o
    void Sel e ctTa rget() {

        // B ounds  o f  the sp here      Bo u n dsb=big Sp h er e.bou nds ;

       // Get  ara ndom point i n si de the bou nds 
        tar get  = new  V ect o r3(
         Ran d om.Ran ge( b.min .x ,  b.max . x ),
       Random.Range( b . mi n .y, b.max.y ), 
      Ran dom .Range( b. mi n.z,b .max.z) 
  );

        / / Find thec los est po in t t h at bel ongsin the  collider f romthat
       ta r get = b i gSphere .Close stP oin t(ta r ge t) ;
    / / N o w t arget ho ld sa ran domp o i n t in sid e th e sph ere

    }

Q:
Par s ing  HTML  usin g QW eb Eleme nt, ho w toex tract an image? 

Istruggletous e Q We bElem e nt. As  an  ex ercise,  I woul d  li ke t o  c apture the "Google "l o go  from pa ge htt p :/ /w w w.google .c om.  The i mageis i n  < div id=" hplogo " .. .> , but I  d on't k no w h owto ex t ract  it. H ow shall  I us e  the "doc" QWe b Element in th e  f o l lo w ingcod e? ("CSS se lect o r" i s ob s cu rej argon  to m e) . 
T h ank you.
from PyQt4 .Q tGui i mport  QApplication 
from PyQt 4 . Q tWebKitimpo r tQ WebView
from P yQt4. QtCore imp o rt QUrl
app= QAppli cation([] ) view = Q Web Vie w() 
vi e w .l oad(QUrl("htt p : //go og le.com" ))view.sh ow( )
d oc= v ie w.page(). currentF ra me () .d ocu mentE l ement() # r un  th is af t er 'lo adFin ishe d' 
A :
To gett he U RL o fth e "G oog le " log o, d o :
e lem = d oc.findFi rst ( "div #h pl ogo")
q string = elem .a ttribute(' st yle ')
reg e x p = QReg Exp("^(.*:)?url\((.*)\) " )
if re gex p.ind exIn (qstring)  >-1:
   i m ageURL  = reg exp.c ap tur e d Texts ( ) [- 1]
I t returnsi m age URL =  " /ima ges/srp r/logo1w.png". It' s  ne cessary to us e a  reg e x pint ha t  ca se bec a u se the URL is a  part of a  s t ri ng. To get the  i mage an d showit on a label , do:
req uest = QN et work 
// Called_when NPC_has to select a_new location_to_move to
__  void_SelectTarget() {

 _   _  //_Bounds_of the sphere
        Bounds b = bigSphere.bounds;

__ ___  // Get a_random point inside the bounds
_ _     target = new_Vector3(
_  _        Random.Range(_b.min.x, b.max.x ),
   _  ___   Random.Range(_b.min.y, b.max.y ),
   _     _  Random.Range( b.min.z, b.max.z )
 _     _);

    _ _ // Find the closest_point that belongs_in the_collider from that
_     _ target =_bigSphere.ClosestPoint(target);

     __ // Now_target_holds_a random_point inside the_sphere

_ __}

 Q:

Parsing HTML using QWebElement, how_to_extract an image?

I struggle to use QWebElement._As an exercise, I_would_like to capture the_"Google" logo from page http://www.google.com._The image is in <div id="hplogo"...>,_but I_don't know_how to extract it. How shall I use the "doc" QWebElement_in the following code? ("CSS selector"_is obscure jargon to_me).
Thank you.
from_PyQt4.QtGui_import QApplication
from PyQt4.QtWebKit_import_QWebView
from PyQt4.QtCore_import QUrl

app = QApplication([])
view = QWebView()
view.load(QUrl("http://google.com"))
view.show()
doc =_view.page().currentFrame().documentElement() _ # run this after 'loadFinished'

A:

To get_the URL of the_"Google"_logo, do:
elem = doc.findFirst("div#hplogo")
qstring = elem.attribute('style')
regexp_= QRegExp("^(.*:)?url\((.*)\)")
if regexp.indexIn(qstring) > -1:
 _  imageURL = regexp.capturedTexts()[-1]

It_returns_imageURL_= "/images/srpr/logo1w.png". It's necessary to_use a regexp in that case_because the URL_is a part of a string. To_get_the image and show it on_a_label, do:
request = QNetwork