<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <tt>Dear list,</tt><br>
    <br>
    <tt>@Jeff: Thanks for the tip. But I need a programmatic way using
      the Python API how to extract the "GetMap" URL.</tt><br>
    <br>
    <tt>Currently I fixed my problem with OWSlib:<br>
      <br>
      <br>
      ```</tt><br>
    <tt></tt>
    <div style="color: #000000;background-color: #ffffff;font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback';font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div style="color: #000000;background-color: #ffffff;font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback';font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div style="color: #000000;background-color: #ffffff;font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback';font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><tt><span style="color: #000000;">d = parse_qs(source)</span></tt></div><tt>
</tt><div><tt><span style="color: #000000;">url_get_capabilities = d[</span></tt><tt><span style="color: #a31515;">'url'</span></tt><tt><span style="color: #000000;">][</span></tt><tt><span style="color: #098658;">0</span></tt><tt><span style="color: #000000;">]</span></tt></div><div><tt><span style="color: #000000;">layers = d[</span></tt><tt><span style="color: #a31515;">'layers'</span></tt><tt><span style="color: #000000;">][</span></tt><tt><span style="color: #098658;">0</span></tt><tt><span style="color: #000000;">]</span></tt></div><tt>
</tt><div><tt><span style="color: #008000;"># request getMap URL via OWSLib</span></tt></div><div><tt><span style="color: #000000;">wms = WebMapService(url_get_capabilities)</span></tt></div><div><tt><span style="color: #000000;">url_get_map = wms.getOperationByName(</span></tt><tt><span style="color: #a31515;">'GetMap'</span></tt><tt><span style="color: #000000;">).methods[</span></tt><tt><span style="color: #098658;">0</span></tt><tt><span style="color: #000000;">][</span></tt><tt><span style="color: #a31515;">'url'</span></tt><span style="color: #000000;"><tt>]</tt></span>
<span style="color: #000000;"><tt><tt>```

</tt></tt><tt></tt><tt>However, I am not that happy with this approach, because OWSlib makes another request to the server. I mean, 
QGIS obviously knows the URL already, but I cannot easily access it Python.

Does anyone else have an idea how the retrieve the "GetMap" URL?

Thanks and best wishes,
Jakob
</tt></span></div></div></div></div>
    <br>
    <br>
    <div class="moz-cite-prefix">On 31.03.20 16:54, Jeff McKenna wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:735d2080-a761-59b2-417b-30b147e7676d@gatewaygeomatics.com">Try
      Richard's great 'QGIS Network Logger' plugin, to see all WMS
      requests.  I've recorded several options here to grab the GetMap
      url: <a class="moz-txt-link-freetext"
href="https://github.com/mapserver/mapserver/wiki/Get-the-Raw-WMS-Request-Generated-by-QGIS"
        moz-do-not-send="true">https://github.com/mapserver/mapserver/wiki/Get-the-Raw-WMS-Request-Generated-by-QGIS</a>
      <br>
      <br>
      -jeff
      <br>
      <br>
      <br>
      <div class="moz-txt-sig"><span class="moz-txt-tag">-- <br>
        </span>Jeff McKenna
        <br>
        MapServer Consulting and Training Services
        <br>
        <a class="moz-txt-link-freetext"
          href="https://gatewaygeomatics.com/" moz-do-not-send="true">https://gatewaygeomatics.com/</a>
        <br>
        <br>
        <br>
        <br>
        On 2020-03-31 11:37 a.m., Jakob Miksch wrote:
        <br>
        <blockquote type="cite" style="color: #000000;">Dear list,
          <br>
          <br>
          I want to extract the "GetMap" URL from WMS layers. For most
          of the WMS layers I can extract it from "layer.source()".
          However this does not work for WMS layers where "GetMap" and
          "GetCapabilities" is different. Like for this layer: <a
            class="moz-txt-link-freetext"
href="https://www.geoportal.rlp.de/mapbender/php/wms.php?inspire=1&layer_id=69694&withChilds=1&INSPIRE=1&"
            moz-do-not-send="true">https://www.geoportal.rlp.de/mapbender/php/wms.php?inspire=1&layer_id=69694&withChilds=1&INSPIRE=1&</a>
          <br>
          <br>
          The only place where I can find the "GetMap" URL is inside the
          "layer.htmlMetadata()" document. From there the URL can be
          extracted using REGEX. But every localization of QGIS (e.g.
          German, French ...) have different terms for the surrounding
          "GetMap" HTML element. This makes this approach quite tricky.
          <br>
          <br>
          Is there any more elegant solution how to retrieve the
          "GetMap" URL from WMS layers?
          <br>
          <br>
          Thanks in advance and best wishes,
          <br>
          Jakob
          <br>
          <br>
        </blockquote>
        <br>
        _______________________________________________
        <br>
        QGIS-Developer mailing list
        <br>
        <a class="moz-txt-link-abbreviated"
          href="mailto:QGIS-Developer@lists.osgeo.org"
          moz-do-not-send="true">QGIS-Developer@lists.osgeo.org</a>
        <br>
        List info: <a class="moz-txt-link-freetext"
          href="https://lists.osgeo.org/mailman/listinfo/qgis-developer"
          moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
        <br>
        Unsubscribe: <a class="moz-txt-link-freetext"
          href="https://lists.osgeo.org/mailman/listinfo/qgis-developer"
          moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Jakob Miksch
Geospatial Development
<a class="moz-txt-link-abbreviated" href="http://www.jakobmiksch.eu">www.jakobmiksch.eu</a></pre>
  </body>
</html>